T
- Type of the objects that will be cached.@StableMinor(version="12.3", sinceVersion="4.0") public class PortalCache<T> extends Object
Modifier and Type | Field and Description |
---|---|
static int |
MAX_AGE_INFINITE
Value that indicates that there is no maximum age for entries in this
cache.
|
Constructor and Description |
---|
PortalCache(String cacheId) |
PortalCache(String cacheId,
boolean autoClone) |
PortalCache(String cacheId,
ICacheDataProvider<T> defaultCacheDataProvider)
Creates a portal cache instance with the specified identifier and
cache data provider.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
clear(ITransaction transaction)
Clears the cache and disables it until the given transaction
ends.
|
static void |
clearAll() |
void |
destroy() |
T |
fetch(String key)
Obtain the value associated with the specified key.
|
T |
fetch(String key,
ICacheDataProvider<T> cacheDataProvider)
Obtain the value associated with the specified key.
|
T |
fetch(String key,
ICacheDataProvider<T> cacheDataProvider,
String... groups)
Obtain the value associated with the specified key and groups.
|
T |
fetch(String key,
String... groups)
Obtain the value associated with the specified key and groups.
|
T |
get(String key) |
static PortalCache |
getCache(String cacheId) |
static Collection<String> |
getCacheIds() |
int |
getCapacity()
Returns the current capacity of this portal cache.
|
String |
getId() |
int |
getMaxAgeSeconds()
Returns the current maximum age for entries in this cache.
|
int |
getSize()
Returns the number of entries currently stored in this cache.
|
ICacheStatistics |
getStatistics() |
void |
put(String key,
T value) |
void |
put(String key,
T value,
String... groups)
Stores the key value along with the groups association.
|
void |
remove(String key) |
void |
remove(String key,
ITransaction transaction)
Removes an entry from the cache now and after the given transaction
ends.
|
void |
removeGroup(String group)
Removes all keys associated with the given group.
|
void |
setCapacity(int newCapacity)
Sets the capacity for this portal cache.
|
PortalCache<T> |
setDefaultCacheMultiDataProvider(ICacheMultiDataProvider<T> cacheMultiDataProvider)
Sets the default cache multi-data provider.
|
void |
setMaxAgeSeconds(int maxAgeSeconds)
Sets the maximum age for entries in this cache.
|
protected void |
setReplicateOnPut()
Experimental feature -
Configure this cache to replicate an entry when it is added to the cache.
|
String |
toString() |
public static final int MAX_AGE_INFINITE
public PortalCache(String cacheId)
public PortalCache(String cacheId, ICacheDataProvider<T> defaultCacheDataProvider)
cacheId
- the cache identifier.defaultCacheDataProvider
- the default cache data provider for this
cache instance.public PortalCache(String cacheId, boolean autoClone)
public static void clearAll()
public String getId()
public int getMaxAgeSeconds()
MAX_AGE_INFINITE
to
indicate there is no maximum age.public void setMaxAgeSeconds(int maxAgeSeconds)
maxAgeSeconds
- the maximum age in seconds,
or MAX_AGE_INFINITE
to indicate there is no maximum age.public PortalCache<T> setDefaultCacheMultiDataProvider(ICacheMultiDataProvider<T> cacheMultiDataProvider)
ICacheDataProvider
or ICacheMultiDataProvider
in this cache.cacheMultiDataProvider
- the cache multi-data provider to set as default.public T fetch(String key) throws PortalException
ICacheDataProvider
or ICacheMultiDataProvider
of this PortalCache is used to read the value, and
the returned values are cached.key
- the key.UnsupportedOperationException
- if there is no ICacheDataProvider
or
ICacheMultiDataProvider
specified for this cache instance.PortalException
- if the loadData
method of the data provider used throws it.RuntimeException
- any runtime exception thrown by the loadData
method of the data provider used is
thrown by this method.public T fetch(String key, String... groups) throws PortalException
ICacheDataProvider
of this
PortalCache is used to read the value, and it is cached.key
- the key.groups
- the groups associated with the key.UnsupportedOperationException
- if there is no ICacheDataProvider
or
ICacheMultiDataProvider
specified for this cache instance.PortalException
- if the loadData
method of the data provider used throws it.RuntimeException
- any runtime exception thrown by the loadData
method of the data provider used is
thrown by this method.public T fetch(String key, ICacheDataProvider<T> cacheDataProvider) throws PortalException
key
- the key.cacheDataProvider
- the data provider used if the value is not
currently available in the cache.PortalException
- if ICacheDataProvider.loadData(String)
throws it.RuntimeException
- any runtime exception thrown by
ICacheDataProvider.loadData(String)
is thrown by this method.public T fetch(String key, ICacheDataProvider<T> cacheDataProvider, String... groups) throws PortalException
key
- the key.cacheDataProvider
- the data provider used if the value is not
currently available in the cache.groups
- the groups associated with the key.PortalException
- if ICacheDataProvider.loadData(String)
throws it.RuntimeException
- any runtime exception thrown by
ICacheDataProvider.loadData(String)
is thrown by this method.public void put(String key, T value, String... groups)
key
- the key.value
- the key value.groups
- one or more groups.public void remove(String key)
public void removeGroup(String group)
group
- the group identifier.public void remove(String key, ITransaction transaction) throws PortalException
key
- the entry key.transaction
- the transaction.PortalException
public void clear()
public void clear(ITransaction transaction) throws PortalException
transaction
- the transaction.PortalException
public int getSize()
public int getCapacity()
public void setCapacity(int newCapacity)
public void destroy()
public ICacheStatistics getStatistics()
protected void setReplicateOnPut()
public static PortalCache getCache(String cacheId)
public static Collection<String> getCacheIds()
LumisXP 12.3.0.200408 - Copyright © 2006–2020 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.