26 #include <olp/core/Config.h>
27 #include "CacheSettings.h"
28 #include "KeyValueCache.h"
30 #ifdef OLP_SDK_ENABLE_DEFAULT_CACHE
35 class DefaultCacheImpl;
161 bool Put(
const std::string& key,
const boost::any& value,
162 const Encoder& encoder, time_t expiry)
override;
174 time_t expiry)
override;
184 boost::any
Get(
const std::string& key,
const Decoder& decoder)
override;
202 bool Remove(
const std::string& key)
override;
221 bool Contains(
const std::string& key)
const override;
262 void Promote(
const std::string& key)
override;
284 time_t expiry)
override;
324 uint64_t
Size(uint64_t new_size);
327 std::shared_ptr<DefaultCacheImpl> impl_;
A default cache that provides a memory LRU cache and persistence of cached key-value pairs.
Definition: DefaultCache.h:57
StorageOpenResult Open(CacheType type)
Creates a new cache of the corresponding type.
CacheType
The cache type.
Definition: DefaultCache.h:72
bool Protect(const KeyValueCache::KeyListType &keys) override
Protects keys from eviction.
uint64_t Size(CacheType cache_type) const
Gets size of the corresponding cache.
void Close()
Closes the cache.
bool RemoveKeysWithPrefix(const std::string &prefix) override
Removes the values with the keys that match the given prefix from the cache.
uint64_t Size(uint64_t new_size)
Sets maximum size for the mutable cache. Evict data that exceeds new maximum size.
bool Release(const KeyValueCache::KeyListType &keys) override
Removes a list of keys from protection.
bool Close(CacheType type)
Closes the cache internally so that it is not keept open and thus blocking others from accessing it.
OperationOutcome< ValueTypePtr > Read(const std::string &key) override
Gets the binary data from the cache.
StorageOpenResult
The storage open result type.
Definition: DefaultCache.h:62
@ ProtectedCacheCorrupted
Definition: DefaultCache.h:65
@ OpenDiskPathFailure
Definition: DefaultCache.h:64
@ Success
Definition: DefaultCache.h:63
void Promote(const std::string &key) override
Promotes a key in the cache LRU when applicable.
bool Put(const std::string &key, const boost::any &value, const Encoder &encoder, time_t expiry) override
Stores the key-value pair in the cache.
DefaultCache(CacheSettings settings={})
Creates the DefaultCache instance.
bool Remove(const std::string &key) override
Removes the key-value pair from the cache.
OperationOutcomeEmpty DeleteByPrefix(const std::string &prefix) override
Removes the values with the keys that match the given prefix from the cache.
bool IsProtected(const std::string &key) const override
Checks if key is protected.
OperationOutcomeEmpty Delete(const std::string &key) override
Removes the key-value pair from the cache.
boost::any Get(const std::string &key, const Decoder &decoder) override
Gets the key-value pair from the cache.
OperationOutcomeEmpty Write(const std::string &key, const ValueTypePtr &value, time_t expiry) override
Stores the raw binary data as a value in the cache.
bool Clear()
Clears the cache content.
bool Contains(const std::string &key) const override
Check if key is in the cache.
void Compact()
Compacts the underlying mutable cache storage.
KeyValueCache::ValueTypePtr Get(const std::string &key) override
Gets the key and binary data from the cache.
StorageOpenResult Open()
Opens the cache to start read and write operations.
bool Put(const std::string &key, const KeyValueCache::ValueTypePtr value, time_t expiry) override
Stores the raw binary data as a value in the cache.
An interface for a cache that expects a key-value pair.
Definition: KeyValueCache.h:47
std::shared_ptr< ValueType > ValueTypePtr
The shared pointer type of the DB entry.
Definition: KeyValueCache.h:60
std::vector< std::string > KeyListType
An alias for the list of keys to be protected or released.
Definition: KeyValueCache.h:63
Represents a request outcome.
Definition: ApiResponse.h:65
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24
Settings for memory and disk caching.
Definition: CacheSettings.h:65