Skip to content

Commit 6fde167

Browse files
jiayuebaofacebook-github-bot
authored andcommitted
Deprecate ItemHandle
Summary: - `ItemHandle` -> `WriteHandle` codemod in external use cases - Remove `ItemHandle` from cachelib codebase Reviewed By: therealgymmy Differential Revision: D37500348 fbshipit-source-id: 4aaf5bed9b1472064770e8845e2bdbd19af230a4
1 parent c533664 commit 6fde167

File tree

9 files changed

+21
-18
lines changed

9 files changed

+21
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## V17
4+
In this version, `CacheAllocator::ItemHandle` is removed. Updating to this version will cause compilation error if `ItemHandle` is still used.
5+
36
## V16
47

58
This version is incompatible with versions below 15. Downgrading from this version directly to a version below 15 will require the cache to be dropped. If you need to downgrade from this version, please make sure you downgrade to version 15 first to avoid dropping the cache.
@@ -8,7 +11,7 @@ This version is incompatible with versions below 15. Downgrading from this versi
811

912
This version is incompatible with any previous versions.
1013

11-
Updating to this version may cause compliation error because:
14+
Updating to this version may cause compilation error because:
1215
- The following APIs are removed:
1316
1. CacheAllocator::allocatePermanent_deprecated.
1417

cachelib/allocator/CacheAllocator.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ class CacheAllocator : public CacheBase {
193193
// safely wraps a pointer to the "const Item"/"Item".
194194
using ReadHandle = typename Item::ReadHandle;
195195
using WriteHandle = typename Item::WriteHandle;
196-
using ItemHandle = WriteHandle;
196+
// Following is deprecated as of allocator version 17 and this line will be
197+
// removed at a future date
198+
// using ItemHandle = WriteHandle;
197199
template <typename UserType,
198200
typename Converter =
199201
detail::DefaultUserTypeConverter<Item, UserType>>

cachelib/allocator/CacheVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace cachelib {
2828
// then you only need to bump this version.
2929
// I.e. you're rolling out a new feature that is cache compatible with previous
3030
// Cachelib instances.
31-
constexpr uint64_t kCachelibVersion = 16;
31+
constexpr uint64_t kCachelibVersion = 17;
3232

3333
// Updating this version will cause RAM cache to be dropped for all
3434
// cachelib users!!! Proceed with care!! You must coordinate with

cachelib/allocator/Util.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ typename T::WriteHandle allocateAccessible(T& cache,
131131
// @return the handle for the item or an invalid handle(nullptr) if the
132132
// allocation failed.
133133
template <typename T>
134-
typename T::ItemHandle allocateAndReplace(T& cache,
135-
PoolId poolId,
136-
typename T::Item::Key key,
137-
uint32_t size,
138-
uint32_t ttlSecs = 0) {
134+
typename T::WriteHandle allocateAndReplace(T& cache,
135+
PoolId poolId,
136+
typename T::Item::Key key,
137+
uint32_t size,
138+
uint32_t ttlSecs = 0) {
139139
auto allocHandle = cache.allocate(poolId, key, size, ttlSecs);
140140
if (!allocHandle) {
141-
return typename T::ItemHandle{};
141+
return typename T::WriteHandle{};
142142
}
143143

144144
cache.insertOrReplace(allocHandle);

cachelib/experimental/objcache/Allocator-inl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ template <typename ItemHandle, typename Item, typename Cache>
2626
ItemHandle* objcacheInitializeZeroRefcountHandle(void* handleStorage,
2727
Item* it,
2828
Cache& alloc) {
29-
return new (handleStorage) typename Cache::ItemHandle{it, alloc};
29+
return new (handleStorage) typename Cache::WriteHandle{it, alloc};
3030
}
3131

3232
// Object-cache's c++ allocator needs to access CacheAllocator directly from
@@ -185,7 +185,7 @@ void* MonotonicBufferResource<CacheDescriptor>::allocateSlow(size_t bytes,
185185
}
186186

187187
template <typename MonotonicBufferResource, typename Cache>
188-
std::pair<typename Cache::ItemHandle, MonotonicBufferResource>
188+
std::pair<typename Cache::WriteHandle, MonotonicBufferResource>
189189
createMonotonicBufferResource(Cache& cache,
190190
PoolId poolId,
191191
folly::StringPiece key,
@@ -234,7 +234,7 @@ createMonotonicBufferResource(Cache& cache,
234234
metadata->buffer = bufferStart;
235235

236236
auto sharedHdl =
237-
detail::objcacheInitializeZeroRefcountHandle<typename Cache::ItemHandle>(
237+
detail::objcacheInitializeZeroRefcountHandle<typename Cache::WriteHandle>(
238238
&metadata->itemHandleStorage, hdl.get(), cache);
239239

240240
return {std::move(hdl), MonotonicBufferResource{sharedHdl}};

cachelib/experimental/objcache/Allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class AllocatorResource {
180180
template <typename CacheT>
181181
struct CacheDescriptor {
182182
using Cache = CacheT;
183-
using ItemHandle = typename CacheT::ItemHandle;
183+
using ItemHandle = typename CacheT::WriteHandle;
184184
using Item = typename CacheT::Item;
185185
using ChainedItem = typename CacheT::ChainedItem;
186186
};

cachelib/experimental/objcache/Persistence.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace objcache {
3232
template <typename SerializationCallback>
3333
class PersistorWorker : public PeriodicWorker {
3434
public:
35-
using ItemHandle = CacheAllocator<LruCacheTrait>::ItemHandle;
35+
using ItemHandle = CacheAllocator<LruCacheTrait>::WriteHandle;
3636
using WorkUnit = std::vector<std::pair<ItemHandle, PoolId>>;
3737
explicit PersistorWorker(SerializationCallback serializationCallback,
3838
folly::MPMCQueue<WorkUnit>& queue,
@@ -79,7 +79,7 @@ template <typename ObjectCache>
7979
class ObjectCachePersistor {
8080
public:
8181
using AccessIterator = CacheAllocator<LruCacheTrait>::AccessIterator;
82-
using ItemHandle = CacheAllocator<LruCacheTrait>::ItemHandle;
82+
using ItemHandle = CacheAllocator<LruCacheTrait>::WriteHandle;
8383
using WorkUnit = std::vector<std::pair<ItemHandle, PoolId>>;
8484
using PersistorWorkerObj =
8585
PersistorWorker<typename ObjectCache::SerializationCallback>;

cachelib/rust/src/cachelib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace facebook {
2727
namespace rust {
2828
namespace cachelib {
2929
using LruAllocatorConfig = facebook::cachelib::LruAllocator::Config;
30-
using LruItemHandle = facebook::cachelib::LruAllocator::ItemHandle;
30+
using LruItemHandle = facebook::cachelib::LruAllocator::WriteHandle;
3131

3232
std::unique_ptr<facebook::cachelib::CacheAdmin> make_cacheadmin(
3333
facebook::cachelib::LruAllocator& cache, const std::string& oncall);

website/docs/Cache_Library_User_Guides/Cross_Host_Cache_Persistence.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ using namespace facebook::cachelib;
240240
using Cache = cachelib::LruAllocator;
241241
using CacheConfig = typename Cache::Config;
242242
using CacheKey = typename Cache::Key;
243-
using CacheItemHandle = typename Cache::ItemHandle;
244243

245244
// cache config
246245
CacheConfig config;
@@ -283,7 +282,6 @@ using namespace facebook::cachelib;
283282
using Cache = cachelib::LruAllocator;
284283
using CacheConfig = typename Cache::Config;
285284
using CacheKey = typename Cache::Key;
286-
using CacheItemHandle = typename Cache::ItemHandle;
287285
288286
// cache config
289287
CacheConfig config;

0 commit comments

Comments
 (0)