25 template<
typename K,
typename V>
35 void clear()
override;
41 template<
typename K,
typename V>
49 }
catch (
const std::exception& err) {
50 LOG(ERROR) <<
"Serializing to JSON failed with error: " << err.what();
53 bool persisted =
false;
56 O_WRONLY | O_CREAT | O_TRUNC,
64 serializedCache.data(),
65 serializedCache.size()
67 persisted = nWritten >= 0 &&
68 (
static_cast<size_t>(nWritten) == serializedCache.size());
70 LOG(ERROR) <<
"Failed to write to " <<
file_ <<
":";
72 LOG(ERROR) <<
"write failed with errno " << errno;
76 LOG(ERROR) <<
"Failed to sync " <<
file_ <<
": errno " << errno;
80 LOG(ERROR) <<
"Failed to close " <<
file_ <<
": errno " << errno;
86 template<
typename K,
typename V>
100 }
catch (
const std::exception& err) {
101 LOG(ERROR) <<
"Deserialization of cache file " <<
file_ 102 <<
" failed with parse error: " << err.what();
107 template<
typename K,
typename V>
110 ::unlink(
file_.c_str());
113 template <
typename K,
typename V,
typename M>
116 std::size_t cacheCapacity,
117 std::chrono::seconds syncInterval,
125 template <
typename K,
typename V,
typename M>
127 std::shared_ptr<folly::Executor>
executor,
129 std::size_t cacheCapacity,
130 std::chrono::seconds syncInterval,
LRUPersistentCache< K, V, M >::Ptr cache_
bool readFile(int fd, Container &out, size_t num_bytes=std::numeric_limits< size_t >::max())
dynamic parseJson(StringPiece range)
~FilePersistenceLayer() override
int fdatasyncNoInt(int fd)
constexpr detail::Map< Move > move
requires E e noexcept(noexcept(s.error(std::move(e))))
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
FilePersistenceLayer(const std::string &file)
folly::Optional< folly::dynamic > load() noexceptoverride
FilePersistentCache(const std::string &file, std::size_t cacheCapacity, std::chrono::seconds syncInterval=std::chrono::duration_cast< std::chrono::seconds >(client::persistence::DEFAULT_CACHE_SYNC_INTERVAL), int nSyncRetries=client::persistence::DEFAULT_CACHE_SYNC_RETRIES)
ssize_t writeFull(int fd, const void *buf, size_t count)
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&...args)
**Optimized Holders **The template hazptr_array< M > provides most of the functionality *of M hazptr_holder s but with faster construction destruction *for M
int openNoInt(const char *name, int flags, mode_t mode)
bool persist(const folly::dynamic &arrayOfKvPairs) noexceptoverride
bool allow_non_string_keys
std::string serialize(dynamic const &dyn, serialization_opts const &opts)