oasys::DurableObjectCache< _DataType > Class Template Reference

#include <DurableStore.h>

Inheritance diagram for oasys::DurableObjectCache< _DataType >:

oasys::Logger List of all members.

Detailed Description

template<typename _DataType>
class oasys::DurableObjectCache< _DataType >

Definition at line 746 of file DurableStore.h.

Public Types

enum  CachePolicy_t { CAP_BY_SIZE, CAP_BY_COUNT }

Public Member Functions

 DurableObjectCache (const char *logpath, size_t capacity, CachePolicy_t policy=CAP_BY_SIZE)
 Constructor.
 ~DurableObjectCache ()
 Destructor.
int put (const SerializableObject &key, const _DataType *data, int flags)
 Add a new object to the cache, initially putting it on the live object list.
int get (const SerializableObject &key, _DataType **data)
 Look up a given object in the cache.
bool is_live (const SerializableObject &key)
 Return whether or not the key is currently live in in the cache.
int release (const SerializableObject &key, const _DataType *data)
 Release the given object, making it eligible for eviction.
int del (const SerializableObject &key)
 Forcibly remove an object from the cache and delete it.
int remove (const SerializableObject &key, const _DataType *data)
 Remove the given entry from the cache but don't delete it.
size_t flush ()
 Flush all evictable (i.e.
void reset_stats ()
 Reset the cache statistics.
iterator begin ()
 Return an iterator at the beginning of the cache.
iterator end ()
 Return an iterator at the end of the cache.
size_t size ()
 Accessors.
size_t count ()
 Accessors.
size_t live ()
 Accessors.
int hits ()
 Accessors.
int misses ()
 Accessors.
int evictions ()
 Accessors.

Protected Types

typedef LRUList< std::string > CacheLRUList
 The LRU list just stores the key for the object in the main cache table.
typedef std::pair< typename
CacheTable::iterator, bool
CacheInsertRet

Protected Member Functions

void get_cache_key (std::string *cache_key, const SerializableObject &key)
 Build a std::string to index the hash map.
bool is_over_capacity (size_t size)
 
Returns:
Whether or not the added item of size puts the cache over the capacity.

void evict_last ()
 Kick the least recently used element out of the cache.

Protected Attributes

size_t size_
 The current size of the cache.
size_t capacity_
 The maximum size of the cache.
int hits_
 Number of times the cache hits.
int misses_
 Number of times the cache misses.
int evictions_
 Number of times the cache evicted an object.
CacheLRUList lru_
 The LRU List of objects.
CacheTable cache_
 The object cache table.
SpinLocklock_
 Lock to protect the in-memory cache.
CachePolicy_t policy_
 Cache policy (see enum above).

Classes

struct  CacheElement
 Type for the cache table elements. More...
class  CacheTable
 The cache table. More...
class  iterator
 Class to represent a cache iterator and still hide the implementation details of the cache table structure. More...


Member Typedef Documentation

template<typename _DataType>
typedef LRUList<std::string> oasys::DurableObjectCache< _DataType >::CacheLRUList [protected]

The LRU list just stores the key for the object in the main cache table.

Definition at line 845 of file DurableStore.h.

template<typename _DataType>
typedef std::pair<typename CacheTable::iterator, bool> oasys::DurableObjectCache< _DataType >::CacheInsertRet [protected]

Definition at line 869 of file DurableStore.h.


Member Enumeration Documentation

template<typename _DataType>
enum oasys::DurableObjectCache::CachePolicy_t

Enumerator:
CAP_BY_SIZE 
CAP_BY_COUNT 

Definition at line 748 of file DurableStore.h.


Constructor & Destructor Documentation

template<typename _DataType>
DurableObjectCache< _DataType >::DurableObjectCache ( const char *  logpath,
size_t  capacity,
CachePolicy_t  policy = CAP_BY_SIZE 
)

Constructor.

Definition at line 1202 of file DurableStore.h.

template<typename _DataType>
DurableObjectCache< _DataType >::~DurableObjectCache (  ) 

Destructor.

Definition at line 1219 of file DurableStore.h.


Member Function Documentation

template<typename _DataType>
int DurableObjectCache< _DataType >::put ( const SerializableObject key,
const _DataType *  data,
int  flags 
)

Add a new object to the cache, initially putting it on the live object list.

Note that this may cause some other object(s) to be evicted from the cache.

Definition at line 1298 of file DurableStore.h.

template<typename _DataType>
int DurableObjectCache< _DataType >::get ( const SerializableObject key,
_DataType **  data 
)

Look up a given object in the cache.

Definition at line 1394 of file DurableStore.h.

template<typename _DataType>
bool DurableObjectCache< _DataType >::is_live ( const SerializableObject key  ) 

Return whether or not the key is currently live in in the cache.

Definition at line 1431 of file DurableStore.h.

template<typename _DataType>
int DurableObjectCache< _DataType >::release ( const SerializableObject key,
const _DataType *  data 
)

Release the given object, making it eligible for eviction.

Definition at line 1458 of file DurableStore.h.

template<typename _DataType>
int DurableObjectCache< _DataType >::del ( const SerializableObject key  ) 

Forcibly remove an object from the cache and delete it.

Definition at line 1502 of file DurableStore.h.

template<typename _DataType>
int DurableObjectCache< _DataType >::remove ( const SerializableObject key,
const _DataType *  data 
)

Remove the given entry from the cache but don't delete it.

Definition at line 1542 of file DurableStore.h.

template<typename _DataType>
size_t DurableObjectCache< _DataType >::flush (  ) 

Flush all evictable (i.e.

not live) objects from the cache.

Returns:
the number of objects evicted

Definition at line 1583 of file DurableStore.h.

template<typename _DataType>
size_t oasys::DurableObjectCache< _DataType >::size (  )  [inline]

Accessors.

Definition at line 806 of file DurableStore.h.

template<typename _DataType>
size_t oasys::DurableObjectCache< _DataType >::count (  )  [inline]

Accessors.

Definition at line 807 of file DurableStore.h.

template<typename _DataType>
size_t oasys::DurableObjectCache< _DataType >::live (  )  [inline]

Accessors.

Definition at line 808 of file DurableStore.h.

template<typename _DataType>
int oasys::DurableObjectCache< _DataType >::hits (  )  [inline]

Accessors.

Definition at line 809 of file DurableStore.h.

template<typename _DataType>
int oasys::DurableObjectCache< _DataType >::misses (  )  [inline]

Accessors.

Definition at line 810 of file DurableStore.h.

template<typename _DataType>
int oasys::DurableObjectCache< _DataType >::evictions (  )  [inline]

Accessors.

Definition at line 811 of file DurableStore.h.

template<typename _DataType>
void oasys::DurableObjectCache< _DataType >::reset_stats (  )  [inline]

Reset the cache statistics.

Definition at line 817 of file DurableStore.h.

template<typename _DataType>
void DurableObjectCache< _DataType >::get_cache_key ( std::string *  cache_key,
const SerializableObject key 
) [protected]

Build a std::string to index the hash map.

Definition at line 1228 of file DurableStore.h.

template<typename _DataType>
bool DurableObjectCache< _DataType >::is_over_capacity ( size_t  size  )  [protected]

Returns:
Whether or not the added item of size puts the cache over the capacity.

Definition at line 1243 of file DurableStore.h.

template<typename _DataType>
void DurableObjectCache< _DataType >::evict_last (  )  [protected]

Kick the least recently used element out of the cache.

Definition at line 1259 of file DurableStore.h.

template<typename _DataType>
iterator oasys::DurableObjectCache< _DataType >::begin (  )  [inline]

Return an iterator at the beginning of the cache.

Definition at line 918 of file DurableStore.h.

template<typename _DataType>
iterator oasys::DurableObjectCache< _DataType >::end (  )  [inline]

Return an iterator at the end of the cache.

Definition at line 924 of file DurableStore.h.


Member Data Documentation

template<typename _DataType>
size_t oasys::DurableObjectCache< _DataType >::size_ [protected]

The current size of the cache.

Definition at line 871 of file DurableStore.h.

template<typename _DataType>
size_t oasys::DurableObjectCache< _DataType >::capacity_ [protected]

The maximum size of the cache.

Definition at line 872 of file DurableStore.h.

template<typename _DataType>
int oasys::DurableObjectCache< _DataType >::hits_ [protected]

Number of times the cache hits.

Definition at line 873 of file DurableStore.h.

template<typename _DataType>
int oasys::DurableObjectCache< _DataType >::misses_ [protected]

Number of times the cache misses.

Definition at line 874 of file DurableStore.h.

template<typename _DataType>
int oasys::DurableObjectCache< _DataType >::evictions_ [protected]

Number of times the cache evicted an object.

Definition at line 875 of file DurableStore.h.

template<typename _DataType>
CacheLRUList oasys::DurableObjectCache< _DataType >::lru_ [protected]

The LRU List of objects.

Definition at line 876 of file DurableStore.h.

template<typename _DataType>
CacheTable oasys::DurableObjectCache< _DataType >::cache_ [protected]

The object cache table.

Definition at line 877 of file DurableStore.h.

template<typename _DataType>
SpinLock* oasys::DurableObjectCache< _DataType >::lock_ [protected]

Lock to protect the in-memory cache.

Definition at line 878 of file DurableStore.h.

template<typename _DataType>
CachePolicy_t oasys::DurableObjectCache< _DataType >::policy_ [protected]

Cache policy (see enum above).

Definition at line 879 of file DurableStore.h.


The documentation for this class was generated from the following file:
Generated on Fri Dec 22 14:48:07 2006 for DTN Reference Implementation by  doxygen 1.5.1