Package org.jboss.util
Class SynchronizedCachePolicy
- java.lang.Object
-
- org.jboss.util.SynchronizedCachePolicy
-
- All Implemented Interfaces:
CachePolicy
public final class SynchronizedCachePolicy extends java.lang.Object implements CachePolicy
A synchronized cache policy wrapper.- Version:
- $Revision$
- See Also:
CachePolicy
-
-
Field Summary
Fields Modifier and Type Field Description private CachePolicydelegate
-
Constructor Summary
Constructors Constructor Description SynchronizedCachePolicy(CachePolicy delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreate()voiddestroy()voidflush()Flushes the cached objects from the cache.java.lang.Objectget(java.lang.Object key)Returns the object paired with the specified key if it's present in the cache, otherwise must return null.voidinsert(java.lang.Object key, java.lang.Object object)Inserts the specified object into the cache following the implemented policy.java.lang.Objectpeek(java.lang.Object key)Returns the object paired with the specified key if it's present in the cache, otherwise must return null.voidremove(java.lang.Object key)Remove the cached object paired with the specified key.intsize()voidstart()voidstop()
-
-
-
Field Detail
-
delegate
private final CachePolicy delegate
-
-
Constructor Detail
-
SynchronizedCachePolicy
public SynchronizedCachePolicy(CachePolicy delegate)
-
-
Method Detail
-
get
public java.lang.Object get(java.lang.Object key)
Description copied from interface:CachePolicyReturns the object paired with the specified key if it's present in the cache, otherwise must return null.
Implementations of this method must have complexity of order O(1). Differently fromCachePolicy.peek(java.lang.Object)this method not only return whether the object is present in the cache or not, but also applies the implemented policy that will "refresh" the cached object in the cache, because this cached object was really requested.- Specified by:
getin interfaceCachePolicy- Parameters:
key- the key paired with the object- Returns:
- the object
- See Also:
CachePolicy.peek(java.lang.Object)
-
peek
public java.lang.Object peek(java.lang.Object key)
Description copied from interface:CachePolicyReturns the object paired with the specified key if it's present in the cache, otherwise must return null.
Implementations of this method must have complexity of order O(1). This method should not apply the implemented caching policy to the object paired with the given key, so that a client can query if an object is cached without "refresh" its cache status. Real requests for the object must be done usingCachePolicy.get(java.lang.Object).- Specified by:
peekin interfaceCachePolicy- Parameters:
key- the key paired with the object- Returns:
- the object
- See Also:
CachePolicy.get(java.lang.Object)
-
insert
public void insert(java.lang.Object key, java.lang.Object object)Description copied from interface:CachePolicyInserts the specified object into the cache following the implemented policy.
Implementations of this method must have complexity of order O(1).- Specified by:
insertin interfaceCachePolicy- Parameters:
key- the key paired with the objectobject- the object to cache- See Also:
CachePolicy.remove(java.lang.Object)
-
remove
public void remove(java.lang.Object key)
Description copied from interface:CachePolicyRemove the cached object paired with the specified key.
Implementations of this method must have complexity of order O(1).- Specified by:
removein interfaceCachePolicy- Parameters:
key- the key paired with the object- See Also:
CachePolicy.insert(java.lang.Object, java.lang.Object)
-
flush
public void flush()
Description copied from interface:CachePolicyFlushes the cached objects from the cache.- Specified by:
flushin interfaceCachePolicy
-
size
public int size()
- Specified by:
sizein interfaceCachePolicy- Returns:
- the size of the cache
-
create
public void create() throws java.lang.Exception- Specified by:
createin interfaceCachePolicy- Throws:
java.lang.Exception
-
start
public void start() throws java.lang.Exception- Specified by:
startin interfaceCachePolicy- Throws:
java.lang.Exception
-
stop
public void stop()
- Specified by:
stopin interfaceCachePolicy
-
destroy
public void destroy()
- Specified by:
destroyin interfaceCachePolicy
-
-