Skip to content

Commit 12822a2

Browse files
xiedeyantufacebook-github-bot
authored andcommitted
Chained item cannot be larger than 4MB (#85)
Summary: Pull Request resolved: #85 Reviewed By: sathyaphoenix Differential Revision: D32806006 Pulled By: leozzx fbshipit-source-id: b973a5bd5a3e1b7a566efb6887de21c0f8f756c4
1 parent 86a11af commit 12822a2

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

cachelib/allocator/CacheItem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,8 @@ class CACHELIB_PACKED_ATTR CacheItem {
472472
// | a | | y | |
473473
// | t | | l | |
474474
// | i | | o | |
475-
// | o | | d | |
476-
// | n | | | |
475+
// | o | | a | |
476+
// | n | | d | |
477477
// | --------------------- |
478478
template <typename CacheTrait>
479479
class CACHELIB_PACKED_ATTR CacheChainedItem : public CacheItem<CacheTrait> {

website/docs/Cache_Library_User_Guides/Write_data_to_cache.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ auto parent_item_handle = cache->allocate(pool_id, "parent", size);
7878
7979
if (parent_item_handle) {
8080
// Call allocateChainedItem() to allocate memory for 3 chained items.
81-
auto chained_item_handle_1 = cache->allocateChainedItem(parent_item_handle, 2 * size);
82-
auto chained_item_handle_2 = cache->allocateChainedItem(parent_item_handle, 4 * size);
83-
auto chained_item_handle_3 = cache->allocateChainedItem(parent_item_handle, 6 * size);
81+
// 4 * size is invalid, Because there are other costs, see getRequiredSize().
82+
// But you can create more chained items.
83+
auto chained_item_handle_1 = cache->allocateChainedItem(parent_item_handle, 1 * size);
84+
auto chained_item_handle_2 = cache->allocateChainedItem(parent_item_handle, 2 * size);
85+
auto chained_item_handle_3 = cache->allocateChainedItem(parent_item_handle, 3 * size);
8486
}
8587
```
8688

website/docs/Cache_Library_User_Guides/chained_items.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ std::unique_ptr<LargeUserData> userData = getLargeUserData();
9797
size_t userDataSize = sizeof(LargeUserData) + sizeof(int) * userData->length;
9898

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

102102
struct CustomParentItem {
103103
size_t numChunks;

0 commit comments

Comments
 (0)