T
- the class of the data stored in the cache.public interface Cache<T>
You can create a new cache using the CacheFactory
component.
Modifier and Type | Method and Description |
---|---|
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.
|
void set(String key, T value)
You can catch this events using
CacheEntryListener.cacheEntryAdded(org.xwiki.cache.event.CacheEntryEvent)
or
CacheEntryListener.cacheEntryModified(org.xwiki.cache.event.CacheEntryEvent)
key
- the associated key used to access the value in the cachevalue
- the value to store in the cache; if null
, the cache entry is removedT get(String key)
key
- the key used to access the value in the cache.null
if there is no value.void remove(String key)
You can catch this events using
CacheEntryListener.cacheEntryRemoved(org.xwiki.cache.event.CacheEntryEvent)
key
- the key used to access the value in the cache.void removeAll()
remove(String)
void addCacheEntryListener(CacheEntryListener<T> listener)
listener
- the implemented listener.void removeCacheEntryListener(CacheEntryListener<T> listener)
listener
- the implemented listener.void dispose()
Copyright © 2004–2022 XWiki. All rights reserved.