/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "storage/cache/storage_cache_types.h" #include "base/basic_types.h" #include #include namespace Storage { class EncryptionKey; namespace Cache { namespace details { class Database; } // namespace details struct Key { uint64 high = 0; uint64 low = 0; }; inline bool operator==(const Key &a, const Key &b) { return (a.high == b.high) && (a.low == b.low); } inline bool operator!=(const Key &a, const Key &b) { return !(a == b); } inline bool operator<(const Key &a, const Key &b) { return std::tie(a.high, a.low) < std::tie(b.high, b.low); } class Database { public: struct Settings { size_type sizeLimit = 0; }; Database(const QString &path, const Settings &settings); void open(EncryptionKey key, FnMut done); void close(FnMut done); void put(const Key &key, QByteArray value, FnMut done); void get(const Key &key, FnMut done); void remove(const Key &key, FnMut done); void clear(FnMut done); ~Database(); private: using Implementation = details::Database; crl::object_on_queue _wrapped; }; } // namespace Cache } // namespace Storage