#include <ace/Hash_Cache_Map_Manager.h>
template<class KEY, class VALUE, class HASH_KEY, class COMPARE_KEYS, class CACHING_STRATEGY, class ATTRIBUTES> class ACE_Hash_Cache_Map_Manager : public ACE_CACHE_MAP_MANAGER {
public:
typedef ACE_Pair<VALUE, ATTRIBUTES> CACHE_VALUE;
typedef ACE_Hash_Map_Manager_Ex<KEY, CACHE_VALUE, HASH_KEY, COMPARE_KEYS, ACE_Null_Mutex> HASH_MAP;typedef ACE_Hash_Map_Entry<KEY, CACHE_VALUE> CACHE_ENTRY;
typedef KEY key_type;
typedef VALUE mapped_type;
ACE_Hash_Cache_Map_Manager ( CACHING_STRATEGY &caching_s, size_t size = ACE_DEFAULT_MAP_SIZE, ACE_Allocator *alloc = 0 );
~ACE_Hash_Cache_Map_Manager (void);
int bind (const KEY &key, const VALUE &value);
int bind ( const KEY &key, const VALUE &value, CACHE_ENTRY *&entry );
int find (const KEY &key, VALUE &value);
int find (const KEY &key);
int find (const KEY &key, CACHE_ENTRY *&entry);
int rebind (const KEY &key, const VALUE &value);
int rebind (const KEY &key, const VALUE &value, VALUE &old_value);
int rebind ( const KEY &key, const VALUE &value, KEY &old_key, VALUE &old_value );
int rebind ( const KEY &key, const VALUE &value, CACHE_ENTRY *&entry );
int trybind (const KEY &key, VALUE &value);
int trybind (const KEY &key, VALUE &value, CACHE_ENTRY *&entry);
int unbind (const KEY &key);
int unbind (const KEY &key, VALUE &value);
int unbind (CACHE_ENTRY *entry);
protected:
typedef ACE_CACHE_MAP_MANAGER ACE_HCMM_BASE;
};
No locking mechanism provided since locking at this level isnt efficient. Locking has to be provided by the application.
ACE_Hash_Cache_Map_Manager (
CACHING_STRATEGY &caching_s,
size_t size = ACE_DEFAULT_MAP_SIZE,
ACE_Allocator *alloc = 0
);
Hash_Cache_Map_Manager
with size
entries.
~ACE_Hash_Cache_Map_Manager (void);
Cache_Map_Manager
and release dynamically allocated
resources.
int bind (const KEY &key, const VALUE &value);
key
with value
. If key
is already in the
MAP then the ENTRY is not changed. Returns 0 if a new entry is
bound successfully, returns 1 if an attempt is made to bind an
existing entry, and returns -1 if failures occur.
int bind (const KEY &key, const VALUE &value, CACHE_ENTRY *&entry);
int find (const KEY &key, VALUE &value);
key,value
in the cache.
int find (const KEY &key);
key
in the cache?
int find (const KEY &key, CACHE_ENTRY *&entry);
int rebind (const KEY &key, const VALUE &value);
key
with value
. If the key
already exists
in the cache then returns 1, on a new bind returns 0 and returns
-1 in case of any failures.
int rebind (const KEY &key, const VALUE &value, VALUE &old_value);
key
with value
, storing the old value into the
"out" parameter old_value
. The function fails if key
is not
in the cache for caches that do not allow user specified keys.
However, for caches that allow user specified keys, if the key is
not in the cache, a new key
/value
association is created.
int rebind (
const KEY &key,
const VALUE &value,
KEY &old_key,
VALUE &old_value
);
key
with value
, storing the old key and value
into the "out" parameters old_key
and old_value
. The
function fails if key
is not in the cache for caches that do not
allow user specified keys. However, for caches that allow user
specified keys, if the key is not in the cache, a new key
/value
association is created.
int rebind (const KEY &key, const VALUE &value, CACHE_ENTRY *&entry);
int trybind (const KEY &key, VALUE &value);
key
with value
if and only if key
is not in the
cache. If key
is already in the cache, then the value
parameter
is overwritten with the existing value in the cache. Returns 0 if a
new key
/value
association is created. Returns 1 if an
attempt is made to bind an existing entry. This function fails
for maps that do not allow user specified keys.
int trybind (const KEY &key, VALUE &value, CACHE_ENTRY *&entry);
int unbind (const KEY &key);
key
from the cache.
int unbind (const KEY &key, VALUE &value);
key
from the cache, and return the value
associated with
key
.
int unbind (CACHE_ENTRY *entry);
kirthika@cs.wustl.edu