org.terracotta.cache
Interface DistributedCache<K,V>

Type Parameters:
K - key type
V - value type
All Superinterfaces:
ConcurrentMap<K,V>, LockableMap<K>, Map<K,V>
All Known Subinterfaces:
IncoherentDistributedCache<K,V>, IncoherentDistributedCacheInternals<K,V>
All Known Implementing Classes:
LocalCache, TerracottaDistributedCache

public interface DistributedCache<K,V>
extends ConcurrentMap<K,V>, LockableMap<K>

A distributed, clustered cache with eviction

Object identity is maintained across the cluster such that an object put into the cache is seen as the same object across all nodes and changes to that object will be maintained across all nodes. Note that this implies that changes to keys or values held in the DistributedCache must be done with appropriate locking on the key or value object to maintain proper Java memory model semantics.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Method Summary
 CacheConfig getConfig()
          Get the current config for the cache.
 TimestampedValue<V> getTimestampedValue(K key)
          Get the value wrapped in a timestamped object.
 TimestampedValue<V> getTimestampedValueQuiet(K key)
          Get the value wrapped in a timestamped object without updating the last usage statistics.
 int localSize()
          Get the number of elements local in the current node.
 void putNoReturn(K key, V value)
          Put the key/value into the map, replacing the existing value if present.
 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.
 void shutdown()
          Shut down the background eviction thread, if any.
 
Methods inherited from interface java.util.concurrent.ConcurrentMap
putIfAbsent, remove, replace, replace
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from interface org.terracotta.locking.LockableMap
createFinegrainedLock, lockEntry, unlockEntry
 

Method Detail

putNoReturn

void putNoReturn(K key,
                 V value)
Put the key/value into the map, replacing the existing value if present.

This 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.

Parameters:
key - Key
value - Value

removeNoReturn

void removeNoReturn(Object key)
Remove the key from the map, if it exists.

This 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.

Parameters:
key - Key

getTimestampedValue

TimestampedValue<V> getTimestampedValue(K key)
Get the value wrapped in a timestamped object.

This value is used entirely for maintaining the creation and last accessed time for TTI and TTL eviction.

Parameters:
key - The key to search for
Returns:
The wrapped value or null if not found

getTimestampedValueQuiet

TimestampedValue<V> getTimestampedValueQuiet(K key)
Get the value wrapped in a timestamped object without updating the last usage statistics.

Parameters:
key - The key to search for
Returns:
The wrapped value or null if not found
See Also:
getTimestampedValue(Object)

removeTimestampedValue

TimestampedValue<V> removeTimestampedValue(K key)
Remove the timestamped value for the given key.

Previous values will be returned as null if they are expired.

Parameters:
key - The key to search for
Returns:
The wrapped value or null if not found or expired

getConfig

CacheConfig getConfig()
Get the current config for the cache.

This may or may not be the same config object as was orignally supplied to the cache.

Returns:
The configuration for this cache

localSize

int localSize()
Get the number of elements local in the current node.

This 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.

Returns:
The local size, in range, such that 0 < localSize < size

shutdown

void shutdown()
Shut down the background eviction thread, if any.



Copyright © 2015 Terracotta, Inc.. All Rights Reserved.