summary refs log tree commit diff
path: root/src/Cache.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-05-08 20:30:09 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-05-08 20:30:09 +0300
commitebed87ea5730f9a49d6cf6d03a2a3a8ef7e2aa52 (patch)
treeb022e968f92dee9c52e73b07de7fadd304cc5299 /src/Cache.cc
parentReplace shared pointers of MatrixClient with a single instance (diff)
downloadnheko-ebed87ea5730f9a49d6cf6d03a2a3a8ef7e2aa52.tar.xz
Don't use shared pointers for cache
Diffstat (limited to 'src/Cache.cc')
-rw-r--r--src/Cache.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Cache.cc b/src/Cache.cc

index 8964c0e0..d80834aa 100644 --- a/src/Cache.cc +++ b/src/Cache.cc
@@ -53,6 +53,25 @@ static constexpr const char *NOTIFICATIONS_DB = "sent_notifications"; using CachedReceipts = std::multimap<uint64_t, std::string, std::greater<uint64_t>>; using Receipts = std::map<std::string, std::map<std::string, uint64_t>>; +namespace { +Cache *instance_ = nullptr; +} + +namespace cache { +void +init(const QString &user_id, QObject *parent) +{ + if (!instance_) + instance_ = new Cache(user_id, parent); +} + +Cache * +client() +{ + return instance_; +} +} + Cache::Cache(const QString &userId, QObject *parent) : QObject{parent} , env_{nullptr}