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 CacheFactory component.

Version:
$Id: 9bbd1d2ae0b97af4f1cf0396be85fb706e6ad37f $

Method Summary
 void addCacheEntryListener(CacheEntryListener<T> listener)
          Add the provided listener to the cache to catch events on entries like add, remove etc.
 void dispose()
          Release all the resources this cache use.
 T get(String key)
           
 void remove(String key)
          Remove the entry associated with the provided key from the cache.
 void removeAll()
          Remove all the entries the cache contains.
 void removeCacheEntryListener(CacheEntryListener<T> listener)
          Remove the provided listener from the list of listeners.
 void set(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) or CacheEntryListener.cacheEntryModified(org.xwiki.cache.event.CacheEntryEvent)

Parameters:
key - the associated key used to access the value in the cache.
value - the value to store in the cache.

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 null if 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.



Copyright © 2004–2013 XWiki. All rights reserved.