32 class PersistentStringCacheImpl;
74 typedef std::unique_ptr<PersistentStringCache>
UPtr;
140 static UPtr open(std::string
const& cache_path, int64_t max_size_in_bytes,
CacheDiscardPolicy policy);
147 static UPtr open(std::string
const& cache_path);
193 bool contains_key(std::string
const& key)
const;
200 int64_t size() const noexcept;
207 int64_t size_in_bytes() const noexcept;
214 int64_t max_size_in_bytes() const noexcept;
222 int64_t disk_size_in_bytes() const;
265 bool put(
std::
string const& key,
266 std::
string const& value,
267 std::chrono::time_point<
std::chrono::system_clock> expiry_time =
std::chrono::system_clock::time_point());
295 bool put(
std::
string const& key,
298 std::chrono::time_point<
std::chrono::system_clock> expiry_time =
std::chrono::system_clock::time_point());
315 bool put(
std::
string const& key,
316 std::
string const& value,
317 std::
string const& metadata,
318 std::chrono::time_point<
std::chrono::system_clock> expiry_time =
std::chrono::system_clock::time_point());
345 bool put(
std::
string const& key,
348 char const* metadata,
349 int64_t metadata_size,
350 std::chrono::time_point<
std::chrono::system_clock> expiry_time =
std::chrono::system_clock::time_point());
377 Optional<
std::
string> get_or_put(
std::
string const& key, Loader const& load_func);
399 Optional<
Data> get_or_put_data(
std::
string const& key, Loader const& load_func);
416 bool put_metadata(
std::
string const& key,
std::
string const& metadata);
442 bool put_metadata(
std::
string const& key,
char const* metadata, int64_t size);
495 template<typename It>
498 std::vector<std::string> keys;
501 keys.push_back(*begin++);
512 void invalidate(std::initializer_list<std::string>
const& keys);
537 std::string
const& key,
538 std::chrono::time_point<std::chrono::system_clock> expiry_time = std::chrono::system_clock::time_point());
558 void resize(int64_t size_in_bytes);
570 void trim_to(int64_t used_size_in_bytes);
612 typedef std::function<void(std::string const& key, CacheEvent ev, PersistentCacheStats const& stats)>
EventCallback;
636 void set_handler(
CacheEvent events, EventCallback cb);
645 std::unique_ptr<internal::PersistentStringCacheImpl> p_;
Simple pair of value and metadata.
Definition: persistent_string_cache.h:79
An entry was refreshed by a call to touch().
std::function< void(std::string const &key, PersistentStringCache &cache)> Loader
Function called by the cache to load an entry after a cache miss.
Definition: persistent_string_cache.h:355
CacheEvent
Event types that can be monitored.
Definition: cache_events.h:38
Top-level namespace for core functionality.
Definition: cache_codec.h:23
std::string metadata
Stores the metadata of an entry. If no metadata exists for an entry, metadata is returned as the empt...
Definition: persistent_string_cache.h:90
std::string value
Stores the value of an entry.
Definition: persistent_string_cache.h:84
An entry was added by a call to put() or get_or_put().
A cache of key-value pairs with persistent storage.
Definition: persistent_string_cache.h:68
An entry was removed by a call to invalidate(), take(), or take_data().
std::function< void(std::string const &key, CacheEvent ev, PersistentCacheStats const &stats)> EventCallback
The type of a handler function.
Definition: persistent_string_cache.h:612
std::unique_ptr< PersistentStringCache > UPtr
Definition: persistent_string_cache.h:74
boost::optional< T > Optional
Convenience typedef for nullable values.
Definition: optional.h:33
CacheDiscardPolicy
Indicates the discard policy to make room for entries when the cache is full.
Definition: cache_discard_policy.h:35
Class that provides (read-only) access to cache statistics and settings.
Definition: persistent_cache_stats.h:42