|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.terracotta.cache.LocalCache<K,V>
K - key typeV - value typepublic class LocalCache<K,V>
A local (non-clustered) cache implementation.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary | |
|---|---|
protected ConcurrentDistributedMap<K,TimestampedValue<V>> |
data
|
| Constructor Summary | |
|---|---|
LocalCache(CacheConfig config)
Construct a cache with the given configuration |
|
| Method Summary | |
|---|---|
void |
clear()
|
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
ClusteredLock |
createFinegrainedLock(K key)
Obtain a fine-grained lock instance for a particular key. |
Set<Map.Entry<K,V>> |
entrySet()
|
void |
evictExpiredLocalElements()
Trigger to walk through the local elements, look for expired elements, and evict them. |
void |
evictOrphanElements(ClusterInfo cluster)
Trigger to walk through the specified set of orphaned elements, check whether they have expired, and evict them from the store. |
V |
get(Object key)
|
CacheConfig |
getConfig()
Get the current config for the cache. |
EvictionStatistics |
getStatistics()
Retrieve the statistics for the current JVM. |
TimeSource |
getTimeSource()
Return the time source used by this cache to generate entry timestamps. |
TimestampedValue<V> |
getTimestampedValue(Object key)
Get the value wrapped in a timestamped object. |
TimestampedValue<V> |
getTimestampedValueQuiet(Object key)
Get the value wrapped in a timestamped object without updating the last usage statistics. |
boolean |
isEmpty()
|
protected boolean |
isEvictionEnabled()
|
boolean |
isStatisticsEnabled()
Returns whether statistics are enabled. |
Set<K> |
keySet()
|
int |
localSize()
Get the number of elements local in the current node. |
void |
lockEntry(K key)
Lock the entry corresponding to this key. |
V |
put(K key,
V value)
|
void |
putAll(Map<? extends K,? extends V> t)
|
V |
putIfAbsent(K key,
V value)
|
void |
putNoReturn(K key,
V value)
Put the key/value into the map, replacing the existing value if present. |
V |
remove(Object key)
|
boolean |
remove(Object key,
Object value)
|
void |
removeNoReturn(Object key)
Remove the key from the map, if it exists. |
TimestampedValue<V> |
removeTimestampedValue(K key)
Remove the timestamped value for the given key. |
V |
replace(K key,
V value)
|
boolean |
replace(K key,
V oldValue,
V newValue)
|
void |
setStatisticsEnabled(boolean enabled)
Toggle statistics being enabled or not. |
void |
setTimeSource(TimeSource timeSource)
This is provided for testing purposes - it lets you override the source of System.currentTimeMillis() so that you can control it yourself in the test. |
void |
shutdown()
Shut down the background eviction thread, if any. |
int |
size()
|
void |
unlockEntry(K key)
Unlock the entry corresponding to this key |
Collection<V> |
values()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Field Detail |
|---|
protected final ConcurrentDistributedMap<K,TimestampedValue<V>> data
| Constructor Detail |
|---|
public LocalCache(CacheConfig config)
config - cache configuration| Method Detail |
|---|
public boolean containsKey(Object key)
containsKey in interface Map<K,V>public V get(Object key)
get in interface Map<K,V>public TimestampedValue<V> getTimestampedValue(Object key)
DistributedCacheThis value is used entirely for maintaining the creation and last accessed time for TTI and TTL eviction.
getTimestampedValue in interface DistributedCache<K,V>key - The key to search for
public TimestampedValue<V> getTimestampedValueQuiet(Object key)
DistributedCache
getTimestampedValueQuiet in interface DistributedCache<K,V>key - The key to search for
DistributedCache.getTimestampedValue(Object)public TimestampedValue<V> removeTimestampedValue(K key)
DistributedCachePrevious values will be returned as null if they are expired.
removeTimestampedValue in interface DistributedCache<K,V>key - The key to search for
public Set<K> keySet()
keySet in interface Map<K,V>
public V put(K key,
V value)
put in interface Map<K,V>public V remove(Object key)
remove in interface Map<K,V>public void clear()
clear in interface Map<K,V>public int size()
size in interface Map<K,V>public int localSize()
DistributedCacheThis number should always be less than size(), and is likely to be different as all cache entries are not required to be stored in the local heap.
localSize in interface DistributedCache<K,V>public void shutdown()
DistributedCache
shutdown in interface DistributedCache<K,V>public void evictExpiredLocalElements()
Evictable
evictExpiredLocalElements in interface Evictable<K>public void evictOrphanElements(ClusterInfo cluster)
Evictable
evictOrphanElements in interface Evictable<K>cluster - The Terracotta cluster info which can be used to obtain the orphaned element listpublic void setTimeSource(TimeSource timeSource)
timeSource - The alternate TimeSource implementationpublic TimeSource getTimeSource()
public Set<Map.Entry<K,V>> entrySet()
entrySet in interface Map<K,V>
public void putNoReturn(K key,
V value)
DistributedCacheThis method differs from the normal put() method only in that it returns void instead of the prior value. This is important in the cluster as it avoids faulting that value to return when it is rarely used.
putNoReturn in interface DistributedCache<K,V>key - Keyvalue - Valuepublic void removeNoReturn(Object key)
DistributedCacheThis method differs from the normal remove() method only in that it returns void instead of the prior value. This is important in the cluster as it avoids faulting that value to return it when it is rarely used.
removeNoReturn in interface DistributedCache<K,V>key - Key
public V putIfAbsent(K key,
V value)
putIfAbsent in interface ConcurrentMap<K,V>
public V replace(K key,
V value)
replace in interface ConcurrentMap<K,V>public boolean isStatisticsEnabled()
Evictable
isStatisticsEnabled in interface Evictable<K>true when statistics are enabled; and false otherwisepublic void setStatisticsEnabled(boolean enabled)
Evictable
setStatisticsEnabled in interface Evictable<K>enabled - true to enable statistics; and false to disable thempublic EvictionStatistics getStatistics()
Evictable
getStatistics in interface Evictable<K>public CacheConfig getConfig()
DistributedCacheThis may or may not be the same config object as was orignally supplied to the cache.
getConfig in interface DistributedCache<K,V>protected boolean isEvictionEnabled()
public boolean remove(Object key,
Object value)
remove in interface ConcurrentMap<K,V>
public boolean replace(K key,
V oldValue,
V newValue)
replace in interface ConcurrentMap<K,V>public boolean containsValue(Object value)
containsValue in interface Map<K,V>public boolean isEmpty()
isEmpty in interface Map<K,V>public void putAll(Map<? extends K,? extends V> t)
putAll in interface Map<K,V>public Collection<V> values()
values in interface Map<K,V>public ClusteredLock createFinegrainedLock(K key)
LockableMap
createFinegrainedLock in interface LockableMap<K>key - the key for which a fine-grained lock has to be constructed
public void lockEntry(K key)
LockableMap
lockEntry in interface LockableMap<K>key - the key for which all entry accesses have to be lockedpublic void unlockEntry(K key)
LockableMap
unlockEntry in interface LockableMap<K>key - the key for which all entry accesses have to be unlocked
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||