Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cachelib/allocator/CacheItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ class CACHELIB_PACKED_ATTR CacheItem {
// | a | | y | |
// | t | | l | |
// | i | | o | |
// | o | | d | |
// | n | | | |
// | o | | a | |
// | n | | d | |
// | --------------------- |
template <typename CacheTrait>
class CACHELIB_PACKED_ATTR CacheChainedItem : public CacheItem<CacheTrait> {
Expand Down
8 changes: 5 additions & 3 deletions website/docs/Cache_Library_User_Guides/Write_data_to_cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ auto parent_item_handle = cache->allocate(pool_id, "parent", size);

if (parent_item_handle) {
// Call allocateChainedItem() to allocate memory for 3 chained items.
auto chained_item_handle_1 = cache->allocateChainedItem(parent_item_handle, 2 * size);
auto chained_item_handle_2 = cache->allocateChainedItem(parent_item_handle, 4 * size);
auto chained_item_handle_3 = cache->allocateChainedItem(parent_item_handle, 6 * size);
// 4 * size is invalid, Because there are other costs, see getRequiredSize().
// But you can create more chained items.
auto chained_item_handle_1 = cache->allocateChainedItem(parent_item_handle, 1 * size);
auto chained_item_handle_2 = cache->allocateChainedItem(parent_item_handle, 2 * size);
auto chained_item_handle_3 = cache->allocateChainedItem(parent_item_handle, 3 * size);
}
```

Expand Down
2 changes: 1 addition & 1 deletion website/docs/Cache_Library_User_Guides/chained_items.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ std::unique_ptr<LargeUserData> userData = getLargeUserData();
size_t userDataSize = sizeof(LargeUserData) + sizeof(int) * userData->length;

// For simplicity, we'll split the user data into 1MB chunks
size_t numChunks = userDataSize / (1024 * 1024 * 1024);
size_t numChunks = userDataSize / (1024 * 1024);

struct CustomParentItem {
size_t numChunks;
Expand Down