org.objectweb.perseus.cache.api

Interface CacheManager

Known Implementing Classes:
BasicCacheManager

public interface CacheManager

This interface is the functional (applicative) view for the Caching Service. All accesses to the cache are made through the Cache instance provided to the applicative level. The primary purpose of the caching service is to improve the overall system performance. The performance gain is from avoidance of costs due to I/O operations related to storage/network devices, recreation-related costs, etc. This service is to be used by several services such as the persistence service and the replication service, among others.

Author:
Luciano Garcia-Banuelos (Luciano.Garcia@imag.fr)

Method Summary

CacheEntry
bind(Object id, Object object)
This method allows a in-memory object (incarnation) to be placed in the cache.
void
fix(CacheEntry ce)
This method notifies the cache manager the intention to use the object identified by lid.
CacheEntry
lookup(Object id)
This method searches the object, identified by lid, within the cache.
void
touch(CacheEntry entry)
Called whenever an object has been accessed.
void
unfix(CacheEntry ce)
This method is used to notify the cache manager that the object identified by lid is not longer to be used.

Method Details

bind

public CacheEntry bind(Object id,
                       Object object)
            throws CacheException
This method allows a in-memory object (incarnation) to be placed in the cache. Such object is identified by the provided lid. If there is currently an object associated with lid, an Exception is thrown.

Parameters:
id - The corresponding object identifier. (It must be generated elsewhere, e.g. by a naming service).
object - The object to be cached.

Returns:
the new CacheEntry add in the cache

Throws:
CacheException - If object/lid are already registered or either object or lid are null.


fix

public void fix(CacheEntry ce)
            throws CacheException
This method notifies the cache manager the intention to use the object identified by lid. The cache manager will mark internally this object, so that this object would not be evicted from the cache.

Parameters:
ce -

Throws:
CacheException - If the object is not in the cache.


lookup

public CacheEntry lookup(Object id)
This method searches the object, identified by lid, within the cache. If such an object has been previously added to the cache the corresponding reference to it will be returned as a result. NULL is returned otherwise. Note that objects must be added to the cache to make it available through it, and that objects could be evicted by the internal replacement algorithm.

Parameters:
id - The corresponding object identifier.

Returns:
The reference to the CacheEntry associated to the id. NULL otherwise.


touch

public void touch(CacheEntry entry)
            throws CacheException
Called whenever an object has been accessed. Thus, this method, gives hints about recency/frequency of use. This hints are used within the replacement algorithm.

Parameters:
entry - The cache entry that has been accessed.

Throws:
CacheException - Whenever an internal error occurs.


unfix

public void unfix(CacheEntry ce)
            throws CacheException
This method is used to notify the cache manager that the object identified by lid is not longer to be used. After executing this operation, the corresponding object is candidate for eviction, according to the replacement algorithm. That means, that the object will remain in the cache, but it may be evicted.

Parameters:
ce -

Throws:
CacheException - If the object has not been previously fixed.


Copyright © 2000-2002 France Telecom S.A., INRIA, IMAG-LSR All Rights Reserved.