Package org.xwiki.cache
Interface Cache<T>
-
- Type Parameters:
T- the class of the data stored in the cache.
- All Known Implementing Classes:
AbstractCache
public interface Cache<T>Cache interface. Used to add/get/remove value from cache which can be local or distributed, with a limited capacity etc. depending of the implementation and configuration.You can create a new cache using the
CacheFactorycomponent.- Version:
- $Id: a041726c64f3309a0b412366dbf0d8f94dbbf0ec $
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddCacheEntryListener(CacheEntryListener<T> listener)Add the provided listener to the cache to catch events on entries like add, remove etc.voiddispose()Release all the resources this cache use.Tget(String key)voidremove(String key)Remove the entry associated with the provided key from the cache.voidremoveAll()Remove all the entries the cache contains.voidremoveCacheEntryListener(CacheEntryListener<T> listener)Remove the provided listener from the list of listeners.voidset(String key, T value)Add a new value or overwrite the existing one associated with the provided key.
-
-
-
Method Detail
-
set
void set(String key, T value)
Add a new value or overwrite the existing one associated with the provided key.You can catch this events using
CacheEntryListener.cacheEntryAdded(org.xwiki.cache.event.CacheEntryEvent)orCacheEntryListener.cacheEntryModified(org.xwiki.cache.event.CacheEntryEvent)- Parameters:
key- the associated key used to access the value in the cachevalue- the value to store in the cache; ifnull, the cache entry is removed
-
get
T get(String key)
- Parameters:
key- the key used to access the value in the cache.- Returns:
- the value associated with the provided key, or
nullif there is no value.
-
remove
void remove(String key)
Remove the entry associated with the provided key from the cache.You can catch this events using
CacheEntryListener.cacheEntryRemoved(org.xwiki.cache.event.CacheEntryEvent)- Parameters:
key- the key used to access the value in the cache.
-
removeAll
void removeAll()
Remove all the entries the cache contains.- See Also:
remove(String)
-
addCacheEntryListener
void addCacheEntryListener(CacheEntryListener<T> listener)
Add the provided listener to the cache to catch events on entries like add, remove etc.- Parameters:
listener- the implemented listener.
-
removeCacheEntryListener
void removeCacheEntryListener(CacheEntryListener<T> listener)
Remove the provided listener from the list of listeners.- Parameters:
listener- the implemented listener.
-
dispose
void dispose()
Release all the resources this cache use.
-
-