Interface Cache
- All Superinterfaces:
Map
- All Known Implementing Classes:
AbstractMap,DefaultGigaMap,GSMapImpl,MapCache
A cache could be scoped, for examples to a JVM, all JVMs on a node, all nodes in a cluster, etc. Operations that are scoped to a cache such as put or load would affect all JVMs in the cache. So the object loaded in 1 JVM would be equally available to all other JVMs in the cache.
Objects are identified in the cache
by a key. A key can be any Java object that implements the uniquely the toString()
method. If the object is to be distributed or persisted (if supported) it must implement
serializable. Each object in the cache will have a CacheEntry object associated with
it. This object will encapsulate the metadata associated with the cached object.
All the
methods that are inherited from Map might throw com.j_spaces.core.client.CacheException. This Exception extends RuntimeException in order to keep the Map API.
- See Also:
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(CacheListener listener) Deprecated.Add a listener to the list of cache listeners.
Optional, not supported by all the implementations, currently supported only by local cache.voidclear()Deprecated.The clear method will remove all objects from the cache including the key and the associated value.booleancontainsKey(Object key) Deprecated.Returns true if the cache contains the specified key.booleancontainsValue(Object value) Deprecated.Returns true if this cache maps one or more keys to the specified value.entrySet()Deprecated.Returns a set view of the objects currently contained in the cache.booleanDeprecated.Equality is based on the Set returned by entrySet.booleanDeprecated.The evict method will remove object from the cache the matches the provided key.Deprecated.The get method will return, from the cache, the object associated with the argument "key".getAll(Collection keys) Deprecated.The getAll method will return, from the cache, a Map of the objects associated with the Collection of keys in argument "keys".getCacheEntry(Object key) Deprecated.Returns the CacheEntry object associated with the object identified by "key".inthashCode()Deprecated.Returns the hash code value for this cache.booleanisEmpty()Deprecated.Return true if entrySet().isEmpty() return true.keySet()Deprecated.Returns a set view of the keys currently contained in the cache.voidDeprecated.The load method provides a means to "pre load" the cache.voidloadAll(Collection keys) Deprecated.The loadAll method provides a means to "pre load" objects into the cache.Deprecated.The peek method will return the object associated with "key" if it currently exists (and is valid) in the cache.Deprecated.The put method adds the object "value" to the cache identified by the object "key".voidDeprecated.Copies all of the mappings from the specified map to the cache.Deprecated.The remove method will delete the object from the cache including the key, the associated value and the associated CacheStatistics object.voidremoveListener(CacheListener listener) Deprecated.Remove a listener from the list of cache listeners.
Optional, not supported by all the implementations, currently supported only by local cacheintsize()Deprecated.Returns the size of this map.values()Deprecated.Returns a collection view of the values contained in this cache.Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Method Details
-
addListener
Deprecated.Add a listener to the list of cache listeners.
Optional, not supported by all the implementations, currently supported only by local cache.- Parameters:
listener- call backCacheListener- Throws:
UnsupportedOperationException- can be thrown by implementations that doesn't support this method
-
clear
void clear()Deprecated.The clear method will remove all objects from the cache including the key and the associated value. -
containsKey
Deprecated.Returns true if the cache contains the specified key. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.- Specified by:
containsKeyin interfaceMap- Parameters:
key- key whose presence in this cache is to be tested.- Returns:
true, if the cache contains the specified key.
-
containsValue
Deprecated.Returns true if this cache maps one or more keys to the specified value. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.- Specified by:
containsValuein interfaceMap- Parameters:
value- value whose presence in this cache is to be tested.- Returns:
true, if the cache contains the specified value.
-
entrySet
Set entrySet()Deprecated.Returns a set view of the objects currently contained in the cache. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called. -
equals
Deprecated.Equality is based on the Set returned by entrySet. -
evict
Deprecated.The evict method will remove object from the cache the matches the provided key.- Parameters:
key- the key to evict- Returns:
true, if the key was evicted
-
get
Deprecated.The get method will return, from the cache, the object associated with the argument "key". If the object is not in the cache, the associated cache loader will be called. If no loader is associated with the object, a null is returned. If a problem is encountered during the retrieving or loading of the object, an exception (to be defined) will be thrown. -
getAll
Deprecated.The getAll method will return, from the cache, a Map of the objects associated with the Collection of keys in argument "keys". If the objects are not in the cache, the associated cache loader will be called. If no loader is associated with an object, a null is returned. If a problem is encountered during the retrieving or loading of the objects, an exception will be thrown.- Parameters:
keys- keys whose associated values are to be returned.- Returns:
- Map of the objects associated with the Collection of keys
- Throws:
CacheException- error accord while loading
-
getCacheEntry
Deprecated.Returns the CacheEntry object associated with the object identified by "key".- Parameters:
key- key whose associated value is to be returned.- Returns:
- the CacheEntry to which this cache maps the specified key, or null if the cache contains no mapping for this key.
-
hashCode
int hashCode()Deprecated.Returns the hash code value for this cache. -
isEmpty
boolean isEmpty()Deprecated.Return true if entrySet().isEmpty() return true. -
keySet
Set keySet()Deprecated.Returns a set view of the keys currently contained in the cache. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called. -
load
Deprecated.The load method provides a means to "pre load" the cache. This method will, load the specified object into the cache using the associated CacheLoader. If the object already exists in the cache, no action is taken. If no loader is associated with the object, no object will be loaded into the cache.- Parameters:
key- key whose associated value is to be loaded.- Throws:
CacheException- error accord while loading
-
loadAll
Deprecated.The loadAll method provides a means to "pre load" objects into the cache. This method will, load the specified objects into the cache using the associated cache loader. If the an object already exists in the cache, no action is taken. If no loader is associated with the object, no object will be loaded into the cache.- Parameters:
keys- keys' Collection whose associated value to be loaded using the associated CacheLoader if this cache doesn't contain it.- Throws:
CacheException- error accord while loading
-
peek
Deprecated.The peek method will return the object associated with "key" if it currently exists (and is valid) in the cache. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.- Parameters:
key- key whose associated value is to be peek.- Returns:
- the value to which this cache maps the specified key, or null if the cache contains no mapping for this key.
-
put
Deprecated.The put method adds the object "value" to the cache identified by the object "key". -
putAll
Deprecated.Copies all of the mappings from the specified map to the cache. -
remove
Deprecated.The remove method will delete the object from the cache including the key, the associated value and the associated CacheStatistics object. -
removeListener
Deprecated.Remove a listener from the list of cache listeners.
Optional, not supported by all the implementations, currently supported only by local cache- Parameters:
listener- theCacheListenerto remove- Throws:
UnsupportedOperationException- can be thrown by implementations that doesn't support this method
-
size
int size()Deprecated.Returns the size of this map. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called. -
values
Collection values()Deprecated.Returns a collection view of the values contained in this cache. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.
-