]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/cache/secondary_cache.cc
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
6 #include "rocksdb/secondary_cache.h"
8 #include "cache/cache_entry_roles.h"
10 namespace ROCKSDB_NAMESPACE
{
14 size_t SliceSize(void* obj
) { return static_cast<Slice
*>(obj
)->size(); }
16 Status
SliceSaveTo(void* from_obj
, size_t from_offset
, size_t length
,
18 const Slice
& slice
= *static_cast<Slice
*>(from_obj
);
19 std::memcpy(out
, slice
.data() + from_offset
, length
);
25 Status
SecondaryCache::InsertSaved(const Slice
& key
, const Slice
& saved
) {
26 static Cache::CacheItemHelper helper
{
27 &SliceSize
, &SliceSaveTo
, GetNoopDeleterForRole
<CacheEntryRole::kMisc
>()};
28 // NOTE: depends on Insert() being synchronous, not keeping pointer `&saved`
29 return Insert(key
, const_cast<Slice
*>(&saved
), &helper
);
32 } // namespace ROCKSDB_NAMESPACE