Package org.jboss.as.ejb3.cache.simple
Class SimpleCache<K,V extends Identifiable<K>>
- java.lang.Object
-
- org.jboss.as.ejb3.cache.simple.SimpleCache<K,V>
-
- Type Parameters:
K- the cache key typeV- the cache value type
- All Implemented Interfaces:
Predicate<K>,Cache<K,V>,org.wildfly.clustering.ee.Restartable,AffinitySupport<K>
public class SimpleCache<K,V extends Identifiable<K>> extends Object implements Cache<K,V>, Predicate<K>
SimpleCacheimplementation using in-memory storage and eager expiration.- Author:
- Paul Ferraro
-
-
Field Summary
-
Fields inherited from interface org.jboss.as.ejb3.cache.Cache
CURRENT_GROUP
-
-
Constructor Summary
Constructors Constructor Description SimpleCache(StatefulObjectFactory<V> factory, Supplier<K> identifierFactory, StatefulTimeoutInfo timeout, org.jboss.as.server.ServerEnvironment environment)
-
Method Summary
All Methods Instance Methods Concrete 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 value)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()org.jboss.ejb.client.AffinitygetStrictAffinity()intgetTotalSize()org.jboss.ejb.client.AffinitygetWeakAffinity(K key)voidrelease(V bean)Decreases the objects usage count.voidremove(K key)Remove and destroy the specified object from cache.voidstart()voidstop()booleantest(K key)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.as.ejb3.cache.Cache
isRemotable
-
-
-
-
Constructor Detail
-
SimpleCache
public SimpleCache(StatefulObjectFactory<V> factory, Supplier<K> identifierFactory, StatefulTimeoutInfo timeout, org.jboss.as.server.ServerEnvironment environment)
-
-
Method Detail
-
start
public void start()
- Specified by:
startin interfaceorg.wildfly.clustering.ee.Restartable
-
stop
public void stop()
- Specified by:
stopin interfaceorg.wildfly.clustering.ee.Restartable
-
getStrictAffinity
public org.jboss.ejb.client.Affinity getStrictAffinity()
- Specified by:
getStrictAffinityin interfaceAffinitySupport<K>
-
getWeakAffinity
public org.jboss.ejb.client.Affinity getWeakAffinity(K key)
- Specified by:
getWeakAffinityin interfaceAffinitySupport<K>
-
getIdentifierFactory
public Supplier<K> getIdentifierFactory()
Description copied from interface:CacheReturns the identifier factory of this cache.- Specified by:
getIdentifierFactoryin interfaceCache<K,V extends Identifiable<K>>- Returns:
- an identifier factory
-
create
public V create()
Description copied from interface:CacheCreates and caches a new instance ofT.
-
discard
public void discard(V value)
Description copied from interface:CacheDiscard the specified object from cache.
-
remove
public void remove(K key)
Description copied from interface:CacheRemove and destroy the specified object from cache.
-
get
public V get(K key)
Description copied from interface:CacheGet the specified object from cache. This will mark the object as being in use, and increase its usage count.
-
contains
public boolean contains(K key)
Description copied from interface:CacheIndicates whether or not the specified key is contained within this cache.
-
release
public void release(V bean)
Description copied from interface:CacheDecreases the objects usage count. If the usage count hits 0 then the object will be released.
-
getCacheSize
public int getCacheSize()
- Specified by:
getCacheSizein interfaceCache<K,V extends Identifiable<K>>
-
getPassivatedCount
public int getPassivatedCount()
- Specified by:
getPassivatedCountin interfaceCache<K,V extends Identifiable<K>>
-
getTotalSize
public int getTotalSize()
- Specified by:
getTotalSizein interfaceCache<K,V extends Identifiable<K>>
-
-