Namespaces |
namespace | qx::cache |
| Provide basic thread-safe cache feature to backup and restore any kind of objects (for example, object fetched from database)
|
namespace | qx::cache::detail |
| Internal helper tools for qx::cache namespace.
|
Files |
file | QxCache.h |
| qx::cache : based on singleton pattern, provide basic thread-safe cache feature to backup and restore any kind of objects (for example, object fetched from database)
|
Functions |
void | qx::cache::max_cost (long l) |
| Set the maximum allowed total cost of the cache to l. If the current total cost is greater than l, some objects are deleted immediately.
|
long | qx::cache::max_cost () |
| Return the maximum allowed total cost of the cache.
|
long | qx::cache::current_cost () |
| Return the current cost used by the cache.
|
long | qx::cache::count () |
| Return the number of objects in the cache.
|
bool | qx::cache::is_empty () |
| Return true if the cache contains no object; otherwise return false.
|
void | qx::cache::clear () |
| Delete all the objects in the cache.
|
bool | qx::cache::exist (const QString &sKey) |
| Return true if the cache contains an object associated with key sKey; otherwise return false.
|
bool | qx::cache::remove (const QString &sKey) |
| Delete the object associated with key sKey. Return true if the object was found in the cache; otherwise return false.
|
template<typename T > |
bool | qx::cache::set (const QString &sKey, T &t, long lCost=1, const QDateTime &dt=QDateTime()) |
| Insert object t into the cache with key sKey, associated cost lCost and insertion date-time dt. Any object with the same key already in the cache will be removed.
|
template<typename T > |
T | qx::cache::get (const QString &sKey) |
| Return the object of type T associated with key sKey, or return default instance of T() if the key does not exist in the cache.
|
template<typename T > |
qx_bool | qx::cache::get (const QString &sKey, T &t, QDateTime &dt) |
| Return true if object t can be fetched with associated key sKey and insertion date-time dt; otherwise return false with an error description.
|
template<typename T > |
qx_bool | qx::cache::get (const QString &sKey, T &t) |
| Return true if object t can be fetched with associated key sKey; otherwise return false with an error description.
|