| QxOrm 1.2.1 C++ Object Relational Mapping library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories

Namespaces | Files | Functions
QxCache : QxOrm library basic thread-safe cache feature to backup and restore any kind of objects (for example, object fetched from database)

## 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.

## Function Documentation

void qx::cache::clear | ( |  | ) | `[inline]`

Delete all the objects in the cache.

Definition at line 146 of file QxCache.h.

long qx::cache::count | ( |  | ) | `[inline]`

Return the number of objects in the cache.

Definition at line 132 of file QxCache.h.

long qx::cache::current_cost | ( |  | ) | `[inline]`

Return the current cost used by the cache.

Definition at line 125 of file QxCache.h.

bool qx::cache::exist | ( | const QString & | sKey | ) | `[inline]`

Return true if the cache contains an object associated with key sKey; otherwise return false.

Definition at line 153 of file QxCache.h.

template<typename T >

qx_bool qx::cache::get | ( | const QString & | sKey,
|  | T & | t,
|  | QDateTime & | dt
| ) |  | `[inline]`

Return true if object t can be fetched with associated key sKey and insertion date-time dt; otherwise return false with an error description.

Definition at line 192 of file QxCache.h.

template<typename T >

T qx::cache::get | ( | const QString & | sKey | ) | `[inline]`

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.

Definition at line 179 of file QxCache.h.

template<typename T >

qx_bool qx::cache::get | ( | const QString & | sKey,
|  | T & | t
| ) |  | `[inline]`

Return true if object t can be fetched with associated key sKey; otherwise return false with an error description.

Definition at line 207 of file QxCache.h.

bool qx::cache::is_empty | ( |  | ) | `[inline]`

Return true if the cache contains no object; otherwise return false.

Definition at line 139 of file QxCache.h.

long qx::cache::max_cost | ( |  | ) | `[inline]`

Return the maximum allowed total cost of the cache.

Definition at line 118 of file QxCache.h.

void qx::cache::max_cost | ( | long | l | ) | `[inline]`

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.

Definition at line 111 of file QxCache.h.

bool qx::cache::remove | ( | const QString & | sKey | ) | `[inline]`

Delete the object associated with key sKey. Return true if the object was found in the cache; otherwise return false.

Definition at line 160 of file QxCache.h.

template<typename T >

bool qx::cache::set | ( | const QString & | sKey,
|  | T & | t,
|  | long | lCost = `1`,
|  | const QDateTime & | dt = `QDateTime()`
| ) |  | `[inline]`

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.

Definition at line 168 of file QxCache.h.

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines