#include <DurableStore.h>
Definition at line 891 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 | get_stats (StringBuffer *buf) |
Get a string representation of the stats in the given string buffer. | |
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 () const |
size_t | count () const |
size_t | live () const |
int | hits () const |
int | misses () const |
int | evictions () const |
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) |
| |
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. | |
SpinLock * | lock_ |
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... |
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 995 of file DurableStore.h.
typedef std::pair<typename CacheTable::iterator, bool> oasys::DurableObjectCache< _DataType >::CacheInsertRet [protected] |
Definition at line 1019 of file DurableStore.h.
enum oasys::DurableObjectCache::CachePolicy_t |
DurableObjectCache< _DataType >::DurableObjectCache | ( | const char * | logpath, | |
size_t | capacity, | |||
CachePolicy_t | policy = CAP_BY_SIZE | |||
) | [inline] |
DurableObjectCache< _DataType >::~DurableObjectCache | ( | ) | [inline] |
int DurableObjectCache< _DataType >::put | ( | const SerializableObject & | key, | |
const _DataType * | data, | |||
int | flags | |||
) | [inline] |
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 1499 of file DurableStore.h.
int DurableObjectCache< _DataType >::get | ( | const SerializableObject & | key, | |
_DataType ** | data | |||
) | [inline] |
bool DurableObjectCache< _DataType >::is_live | ( | const SerializableObject & | key | ) | [inline] |
Return whether or not the key is currently live in in the cache.
Definition at line 1632 of file DurableStore.h.
int DurableObjectCache< _DataType >::release | ( | const SerializableObject & | key, | |
const _DataType * | data | |||
) | [inline] |
Release the given object, making it eligible for eviction.
Definition at line 1659 of file DurableStore.h.
int DurableObjectCache< _DataType >::del | ( | const SerializableObject & | key | ) | [inline] |
Forcibly remove an object from the cache and delete it.
Definition at line 1703 of file DurableStore.h.
int DurableObjectCache< _DataType >::remove | ( | const SerializableObject & | key, | |
const _DataType * | data | |||
) | [inline] |
Remove the given entry from the cache but don't delete it.
Definition at line 1743 of file DurableStore.h.
size_t DurableObjectCache< _DataType >::flush | ( | ) | [inline] |
Flush all evictable (i.e.
not live) objects from the cache.
Definition at line 1784 of file DurableStore.h.
size_t oasys::DurableObjectCache< _DataType >::size | ( | ) | const [inline] |
Accessors
Definition at line 951 of file DurableStore.h.
size_t oasys::DurableObjectCache< _DataType >::count | ( | ) | const [inline] |
Accessors
Definition at line 952 of file DurableStore.h.
size_t oasys::DurableObjectCache< _DataType >::live | ( | ) | const [inline] |
Accessors
Definition at line 953 of file DurableStore.h.
int oasys::DurableObjectCache< _DataType >::hits | ( | ) | const [inline] |
Accessors
Definition at line 954 of file DurableStore.h.
int oasys::DurableObjectCache< _DataType >::misses | ( | ) | const [inline] |
Accessors
Definition at line 955 of file DurableStore.h.
int oasys::DurableObjectCache< _DataType >::evictions | ( | ) | const [inline] |
Accessors
Definition at line 956 of file DurableStore.h.
void DurableObjectCache< _DataType >::get_stats | ( | StringBuffer * | buf | ) | [inline] |
Get a string representation of the stats in the given string buffer.
Definition at line 1410 of file DurableStore.h.
void oasys::DurableObjectCache< _DataType >::reset_stats | ( | ) | [inline] |
void DurableObjectCache< _DataType >::get_cache_key | ( | std::string * | cache_key, | |
const SerializableObject & | key | |||
) | [inline, protected] |
bool DurableObjectCache< _DataType >::is_over_capacity | ( | size_t | size | ) | [inline, protected] |
Definition at line 1444 of file DurableStore.h.
void DurableObjectCache< _DataType >::evict_last | ( | ) | [inline, protected] |
Kick the least recently used element out of the cache.
Definition at line 1460 of file DurableStore.h.
iterator oasys::DurableObjectCache< _DataType >::begin | ( | ) | [inline] |
iterator oasys::DurableObjectCache< _DataType >::end | ( | ) | [inline] |
size_t oasys::DurableObjectCache< _DataType >::size_ [protected] |
size_t oasys::DurableObjectCache< _DataType >::capacity_ [protected] |
int oasys::DurableObjectCache< _DataType >::hits_ [protected] |
int oasys::DurableObjectCache< _DataType >::misses_ [protected] |
int oasys::DurableObjectCache< _DataType >::evictions_ [protected] |
CacheLRUList oasys::DurableObjectCache< _DataType >::lru_ [protected] |
CacheTable oasys::DurableObjectCache< _DataType >::cache_ [protected] |
SpinLock* oasys::DurableObjectCache< _DataType >::lock_ [protected] |
CachePolicy_t oasys::DurableObjectCache< _DataType >::policy_ [protected] |