// Default value is false, Get() will throw an exception instead of
// returning nullptr.
//
// Required: no
staticconstexprbool kMayReturnNull = false;
};
} // namespace example
The query can be a std::string. But due to non-guaranteed order of static data members initialization, std::string should be returned from a static member function, please see the following code snippet.
Policy may have static function GetLastKnownUpdated. It should be used when new entries from database are taken via revision, identifier, or anything else, but not timestamp of the last update. If this function is supplied, new entries are taken from db with condition 'WHERE kUpdatedField > GetLastKnownUpdated(cache_container)'. Otherwise, condition is 'WHERE kUpdatedField > last_update - correction_'. See the following code snippet for an example of usage
In case one provides a custom CacheContainer within Policy, it is notified of Update completion via its public member function OnWritesDone, if any. See the following code snippet for an example of usage:
class UserSpecificCacheWithWriteNotification {
public:
void insert_or_assign(int, MyStructure&&) {}
staticsize_t size() { return 0; }
void OnWritesDone() {}
};
Forward Declaration
To forward declare a cache you can forward declare a trait and include userver/cache/base_postgres_cache_fwd.hpp header. It is also useful to forward declare the cache value type.