#pragma once #include #include template T fromString(const std::string &); template std::string toString(const T &); template drogon::Task getFromCache( const std::string &key, const drogon::nosql::RedisClientPtr &client) noexcept(false) { auto value = co_await client->execCommandCoro("get %s", key.data()); co_return fromString(value.asString()); } template drogon::Task<> updateCache( const std::string &key, T &&value, const drogon::nosql::RedisClientPtr &client) noexcept(false) { std::string vstr = toString(std::forward(value)); co_await client->execCommandCoro("set %s %s", key.data(), vstr.data()); }