diff --git a/cachelib/allocator/CacheItem.h b/cachelib/allocator/CacheItem.h index 2b474d48a3..fc45b2084d 100644 --- a/cachelib/allocator/CacheItem.h +++ b/cachelib/allocator/CacheItem.h @@ -472,8 +472,8 @@ class CACHELIB_PACKED_ATTR CacheItem { // | a | | y | | // | t | | l | | // | i | | o | | -// | o | | d | | -// | n | | | | +// | o | | a | | +// | n | | d | | // | --------------------- | template class CACHELIB_PACKED_ATTR CacheChainedItem : public CacheItem { diff --git a/website/docs/Cache_Library_User_Guides/Write_data_to_cache.md b/website/docs/Cache_Library_User_Guides/Write_data_to_cache.md index 11a998cf62..a046735ad7 100644 --- a/website/docs/Cache_Library_User_Guides/Write_data_to_cache.md +++ b/website/docs/Cache_Library_User_Guides/Write_data_to_cache.md @@ -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); } ``` diff --git a/website/docs/Cache_Library_User_Guides/chained_items.md b/website/docs/Cache_Library_User_Guides/chained_items.md index 6ab8602ba7..dcaf68408a 100644 --- a/website/docs/Cache_Library_User_Guides/chained_items.md +++ b/website/docs/Cache_Library_User_Guides/chained_items.md @@ -97,7 +97,7 @@ std::unique_ptr 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;