Save This Page
Home » jboss-5.0.0.CR1-src » org » jboss » util » [javadoc | source]
org.jboss.util
public interface: CachePolicy [javadoc | source]

All Known Implementing Classes:
    TimedCachePolicy, LRUStatefulContextCachePolicy, LRUPool, NoPassivationCachePolicy, LRUCachePolicy, SynchronizedCachePolicy, TxCache, DistributedTimedCachePolicy, PreparedStatementCache, LRUEnterpriseContextCachePolicy

Interface that specifies a policy for caches.

Implementation classes can implement a LRU policy, a random one, a MRU one, or any other suitable policy.

Method from org.jboss.util.CachePolicy Summary:
create,   destroy,   flush,   get,   insert,   peek,   remove,   size,   start,   stop
Method from org.jboss.util.CachePolicy Detail:
 public  void create() throws Exception
    create the service, do expensive operations etc
 public  void destroy()
    destroy the service, tear down
 public  void flush()
    Flushes the cached objects from the cache.
 public Object get(Object key)
    Returns 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 from #peek 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.
 public  void insert(Object key,
    Object object)
    Inserts the specified object into the cache following the implemented policy.
    Implementations of this method must have complexity of order O(1).
 public Object peek(Object key)
    Returns 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 using #get .
 public  void remove(Object key)
    Remove the cached object paired with the specified key.
    Implementations of this method must have complexity of order O(1).
 public int size()
    Get the size of the cache.
 public  void start() throws Exception
    start the service, create is already called
 public  void stop()
    stop the service