QxOrm  1.4.9
C++ Object Relational Mapping library
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 >
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 148 of file QxCache.h.

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

Return the number of objects in the cache.

Definition at line 134 of file QxCache.h.

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

Return the current cost used by the cache.

Definition at line 127 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 155 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 181 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 195 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 211 of file QxCache.h.

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

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

Definition at line 141 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 113 of file QxCache.h.

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

Return the maximum allowed total cost of the cache.

Definition at line 120 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 162 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 170 of file QxCache.h.