public final class DirectMappedCache<Key,Value> extends Object implements CascadingCache<Key,Value>
CascadingCache
interface following the semantics of
http://en.wikipedia.org/wiki/CPU_cache#Direct-mapped_cache. The Cache is backed by an array that stays constant in size.
Unlike other implementation of a Map a hash collision will lead to the entry being overwritten.
The CacheEvictionCallback
is called with the entry that will be overwritten.
Use this cache if the keys are arriving in a random if not uniformly distributed order in order to reduce the number
of hash and equality comparisons.
If duplicate keys are clustered near each other in the incoming tuple stream, consider the LRUHashMapCache
cache
instead.
DirectMappedCache does not permit null
keys nor null
valuesModifier and Type | Field and Description |
---|---|
boolean |
initialized |
Constructor and Description |
---|
DirectMappedCache() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<Key,Value>> |
entrySet() |
Value |
get(Object key) |
int |
getCapacity()
Returns the capacity of this cache.
|
void |
initialize()
Method to initialize the Cache.
|
boolean |
isEmpty() |
Set<Key> |
keySet() |
Value |
put(Key key,
Value value) |
void |
putAll(Map<? extends Key,? extends Value> m) |
Value |
remove(Object key) |
void |
setCacheEvictionCallback(CacheEvictionCallback cacheEvictionCallback)
Sets the
CacheEvictionCallback of this Cache. |
void |
setCapacity(int capacity)
Sets the capacity of the Cache.
|
int |
size() |
Collection<Value> |
values() |
public boolean initialized
public DirectMappedCache()
public boolean containsKey(Object key)
containsKey
in interface Map<Key,Value>
public boolean containsValue(Object value)
containsValue
in interface Map<Key,Value>
public int getCapacity()
CascadingCache
getCapacity
in interface CascadingCache<Key,Value>
public void setCacheEvictionCallback(CacheEvictionCallback cacheEvictionCallback)
CascadingCache
CacheEvictionCallback
of this Cache.setCacheEvictionCallback
in interface CascadingCache<Key,Value>
public void setCapacity(int capacity)
CascadingCache
setCapacity
in interface CascadingCache<Key,Value>
public void initialize()
CascadingCache
initialize
in interface CascadingCache<Key,Value>
Copyright © 2007-2015 Concurrent, Inc. All Rights Reserved.