Package org.jboss.as.ejb3.cache
Interface Cache<K,V extends Identifiable<K>>
-
- All Superinterfaces:
AffinitySupport<K>,Restartable
- All Known Implementing Classes:
DistributableCache,SimpleCache
public interface Cache<K,V extends Identifiable<K>> extends Restartable, AffinitySupport<K>
Cache a stateful object and make sure any life cycle callbacks are called at the appropriate time.- Author:
- Carlo de Wolf
-
-
Field Summary
Fields Modifier and Type Field Description static ThreadLocal<Object>CURRENT_GROUP
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleancontains(K key)Indicates whether or not the specified key is contained within this cache.Vcreate()Creates and caches a new instance ofT.voiddiscard(V obj)Discard the specified object from cache.Vget(K key)Get the specified object from cache.intgetCacheSize()Supplier<K>getIdentifierFactory()Returns the identifier factory of this cache.intgetPassivatedCount()intgetTotalSize()default booleanisRemotable(Throwable throwable)Checks whether the suppliedThrowableis remotable meaning it can be safely sent to the client over the wire.voidrelease(V obj)Decreases the objects usage count.voidremove(K key)Remove and destroy the specified object from cache.-
Methods inherited from interface org.wildfly.clustering.ejb.AffinitySupport
getStrictAffinity, getWeakAffinity
-
Methods inherited from interface org.wildfly.clustering.ee.Restartable
start, stop
-
-
-
-
Field Detail
-
CURRENT_GROUP
static final ThreadLocal<Object> CURRENT_GROUP
-
-
Method Detail
-
create
V create()
Creates and caches a new instance ofT.- Returns:
- a new
T
-
get
V get(K key)
Get the specified object from cache. This will mark the object as being in use, and increase its usage count.- Parameters:
key- the identifier of the object- Returns:
- the object, or null if it does not exist
-
release
void release(V obj)
Decreases the objects usage count. If the usage count hits 0 then the object will be released.- Parameters:
obj- the object
-
contains
boolean contains(K key)
Indicates whether or not the specified key is contained within this cache.- Parameters:
key- the cache key- Returns:
trueif the key is present in the cache,falseotherwise.
-
discard
void discard(V obj)
Discard the specified object from cache.- Parameters:
obj- the object to discard
-
remove
void remove(K key)
Remove and destroy the specified object from cache.- Parameters:
key- the identifier of the object
-
getCacheSize
int getCacheSize()
-
getPassivatedCount
int getPassivatedCount()
-
getTotalSize
int getTotalSize()
-
isRemotable
default boolean isRemotable(Throwable throwable)
Checks whether the suppliedThrowableis remotable meaning it can be safely sent to the client over the wire.
-
-