Novell exteNd
Director 5.2 API

com.sssw.fw.api
Interface EbiCacheHolder

All Superinterfaces:
Serializable
All Known Subinterfaces:
EbiSession, EbiSrvLifetimeCacheHolder

public interface EbiCacheHolder
extends Serializable

Interface for a cache holder. This interface defines caching methods for the session-lifetime cache holder (EbiSession) and the server-lifetime cache holder (EbiSrvLifetimeCacheHolder). A cache holder can store content in the object cache container or the jointly managed memory and disk cache containers. For more about cache containers, see EbiCacheManager.

A cache holder lets you manage cached content. For the server-lifetime cache, the default cache holder is the global cache holder, which is available as long as the cache is enabled. You can define additional cache holders to provide finer-grained management of cached objects.

Each piece of cached content is called a cache entry, which has an application-defined key and the content itself. The cache holder lets you manipulate cache entries using keys and lets you get a list of keys in use. You can use a single key or a compound key. The compound keys are provided as a convenience to help you organize cached content by object type and component. Director concatenates the parts of the compound key into a single key.

When working with cache entries, it is important to remember that content can be flushed and disappear at any time according to the rules set in the cache configuration. When getting content, always check whether it was successfully returned.

The object, memory, and disk caches are all local to a particular server. If you are using the cache coordinator in a server cluster, then when you call methods in EbiSrvLifetimeCacheHolder to put content in the cache, you can also trigger cache invalidation in order to keep the server caches in sync. caching methods in EbiCacheHolder do not trigger cache invalidation.

See Also:
EbiCacheManager, EbiCacheEntry, EboFactory.getServerLifetimeCacheHolder(String)

Method Summary
 void clearCache(Object key, boolean flag)
          Clears cached content associated with this cache holder in both the object cache and the memory/disk cache.
 void clearCache(String objectType)
          Clears the cached objects that has the specified object type.
 boolean containsContent(Object key)
          Checks if content for the specified content key is currently in the cache for this cache holder.
 void displayCacheEntries()
          Displays the existing cache entries.
 Collection getCachedObjects()
          Gets all the cached objects for this cache holder from all the cache containers: object, memory and disk.
 Enumeration getContentKeys()
          Gets an enumeration of keys for the content for this cache holder in all the cache containers: object, memory and disk.
 String getIdentifier()
          Gets the cache holder's ID.
 int getNumberOfCachedEntries()
          Gets the number of entries for this cache holder in all the cache containers: object, memory and disk.
 Object getObjectInCache(Object key)
          Gets a cached object from the object cache.
 Object getObjectInCache(String componentKey, String contentKey)
          Gets a cached object that is managed by the object cache container of the cache manager.
 Object getObjectInCache(String objectType, String componentKey, String contentKey)
          Gets a cached object from the object cache using a 3-part key.
 EbiCacheEntry getValueInCache(Object key)
          Gets cached content from the memory cache or disk cache.
 EbiCacheEntry getValueInCache(String objectType, String contentKey)
          Gets a cached value that is managed by the memory/disk cache containers of the cache manager.
 void putObjectInCache(Object key, Object obj)
          Puts content in the object cache.
 void putObjectInCache(String objectType, String contentKey, Object obj)
          Puts content in the cache managed by the object cache container of the cache manager.
 void putObjectInCache(String objectType, String componentKey, String contentKey, Object obj)
          Puts content in the object cache using a 3-part key.
 void putValueInCache(Object key, byte[] data, boolean useDisk)
          Stores a value in the memory/disk cache container of the cache manager with the option of not resorting to disk caching.
 void putValueInCache(Object key, int contentType, long contentSize, InputStream in)
          Puts content in the memory cache or disk cache.
 void removeObjectInCache(Object key)
          Removes content associated with this cache holder from the object cache.
 void removeObjectInCache(String objectType, String contentKey)
          Removes a cached object that is managed by the object cache container of the cache manager.
 void removeObjectInCache(String objectType, String componentKey, String contentKey)
          Removes content associated with this cache holder from the object cache using a 3-part key.
 void removeValueInCache(Object key)
          Removes content associated with this cache holder from the memory or disk cache.
 void removeValueInCache(String componentKey, String contentKey)
          Removes content associated with this cache holder from the memory or disk cache using a 2-part key.
 void setIdentifier(String id)
          Sets the cache holder's identifier.
 

Method Detail

getIdentifier

public String getIdentifier()
Gets the cache holder's ID. For cache holders created by the application, the ID was defined when the application created the cache holder. You can also change the ID with EbiCacheHolder.setIdentifier(String).
Returns:
The ID of the cache holder.

setIdentifier

public void setIdentifier(String id)
Sets the cache holder's identifier.
Parameters:
id - An ID for the cache holder.

containsContent

public boolean containsContent(Object key)
Checks if content for the specified content key is currently in the cache for this cache holder.
Parameters:
key - An Object that serves as a content key.
Returns:
Boolean true if there is content in the cache with the specified key, otherwise false.

getContentKeys

public Enumeration getContentKeys()
Gets an enumeration of keys for the content for this cache holder in all the cache containers: object, memory and disk.
Returns:
An Enumeration of content keys.

getNumberOfCachedEntries

public int getNumberOfCachedEntries()
Gets the number of entries for this cache holder in all the cache containers: object, memory and disk.
Returns:
The number of currently cached entries.

getCachedObjects

public Collection getCachedObjects()
Gets all the cached objects for this cache holder from all the cache containers: object, memory and disk.
Returns:
A collection of cached objects.

getObjectInCache

public Object getObjectInCache(String objectType,
                               String componentKey,
                               String contentKey)
Gets a cached object from the object cache using a 3-part key. The key for the cached object is a concatenation of an application-defined object type, component key, and content key. Only the component key is required; the other keys can be null.
Parameters:
objectType - Application-defined type of the cached object; for example, style, page, data.
componentKey - Application-defined key for the component that owns the object.
contentKey - Application-defined content key for the object.
Returns:
The cached object.

getObjectInCache

public Object getObjectInCache(String componentKey,
                               String contentKey)
Gets a cached object that is managed by the object cache container of the cache manager.
Parameters:
objectType - type of the cached object (style, page, etc.)
contentKey - the content key for the object
Returns:
the cached object.

getObjectInCache

public Object getObjectInCache(Object key)
Gets a cached object from the object cache.
Parameters:
key - Key for the cached object.
Returns:
The cached object.

getValueInCache

public EbiCacheEntry getValueInCache(String objectType,
                                     String contentKey)
Gets a cached value that is managed by the memory/disk cache containers of the cache manager.
Parameters:
objectType - type of the cached object (style, page, etc.)
contentKey - the content key for the object
Returns:
an EbiCacheEntry object that contains the cached value.

getValueInCache

public EbiCacheEntry getValueInCache(Object key)
Gets cached content from the memory cache or disk cache. You don't need to know which cache was used.
Parameters:
key - Key for the cached content.
Returns:
An EbiCacheEntry object that contains the cached content.

putObjectInCache

public void putObjectInCache(String objectType,
                             String componentKey,
                             String contentKey,
                             Object obj)
Puts content in the object cache using a 3-part key. This method does not trigger cache invalidation, meaning the cache coordinator does not resynchronize the caches across a server cluster.
Parameters:
objectType - Application-defined type of the cached object; for example, style, page, or data.
componentKey - Application-defined key for the component that owns the object.
contentKey - Application-defined content key for the object.
obj - Object to be cached; cannot be null.
See Also:
EbiSrvLifetimeCacheHolder.putObjectInCache(String, String, String, Object, int)

putObjectInCache

public void putObjectInCache(String objectType,
                             String contentKey,
                             Object obj)
Puts content in the cache managed by the object cache container of the cache manager. This method should be called when putting the object in cache the first time. This method does not trigger cache invalidation, meaning the cache coordinator does not resynchronize the caches across a server cluster.
Parameters:
objectType - Type of the cached object.
contentKey - Application-defined content key for the object.
obj - Object to be cached; cannot be null.
See Also:
#putObjectInCache(String, String, Object, int)

putObjectInCache

public void putObjectInCache(Object key,
                             Object obj)
Puts content in the object cache. This method does not trigger cache invalidation, meaning the cache coordinator does not resynchronize the caches across a server cluster.
Parameters:
key - Key for the cached content. The key can be any object, not just a String.
obj - The object to be cached; cannot be null.
See Also:
EbiSrvLifetimeCacheHolder.putObjectInCache(Object, Object, int)

putValueInCache

public void putValueInCache(Object key,
                            int contentType,
                            long contentSize,
                            InputStream in)
Puts content in the memory cache or disk cache. The cache manager chooses the appropriate cache based on the content's size and the configuration settings for the cache. Content that exceeds the size limit for the memory cache is stored on disk. This method does not trigger cache invalidation, meaning the cache coordinator does not resynchronize the caches across a server cluster.
Parameters:
key - Key for the cached content. The key can be any object, not just a String.
contentType - An integer identifying the content type (text, image, object). Use these values from EbiCacheConstants:
contentSize - Size of the content in bytes.
in - An input stream for the content data.

putValueInCache

public void putValueInCache(Object key,
                            byte[] data,
                            boolean useDisk)
Stores a value in the memory/disk cache container of the cache manager with the option of not resorting to disk caching.
Parameters:
key - the content key
contentSize - the content size
data - data
useDisk - if false, do not attempt to utilize disk caching

removeObjectInCache

public void removeObjectInCache(String objectType,
                                String componentKey,
                                String contentKey)
Removes content associated with this cache holder from the object cache using a 3-part key.
Parameters:
objectType - Application-defined type of the cached object; for example, style, page, data.
componentKey - Application-defined key for the component that owns the object.
contentKey - Application-defined content key for the object.

removeObjectInCache

public void removeObjectInCache(String objectType,
                                String contentKey)
Removes a cached object that is managed by the object cache container of the cache manager.
Parameters:
objectType - type of the cached object (style, page, etc.)
contentKey - the content key for the object

removeObjectInCache

public void removeObjectInCache(Object key)
Removes content associated with this cache holder from the object cache.
Parameters:
key - Key for the cached content.

removeValueInCache

public void removeValueInCache(String componentKey,
                               String contentKey)
Removes content associated with this cache holder from the memory or disk cache using a 2-part key.
Parameters:
componentKey - Application-defined key for the component that owns the object.
contentKey - Application-defined content key for the object.

removeValueInCache

public void removeValueInCache(Object key)
Removes content associated with this cache holder from the memory or disk cache.
Parameters:
key - Key for the cached content.

clearCache

public void clearCache(Object key,
                       boolean flag)
Clears cached content associated with this cache holder in both the object cache and the memory/disk cache.

If the flag parameter is set to false, clearCache() searches for keys with an exact match and removes the corresponding content from the cache.

If the flag parameter is set to true:

Parameters:
key - Key of the contents to be cleared.
flag - Boolean true means use the specified key as a prefix when matching to keys in the cache. False means match keys exactly. When key is null, flag is ignored and all content is removed.

clearCache

public void clearCache(String objectType)
Clears the cached objects that has the specified object type. If you used a 3-part key, which includes an object type, when you added the content, then you can use this method to clear all content that has that type.
Parameters:
objectType - Application-defined object type associated with the cached objects.
See Also:
EbiCacheHolder.putObjectInCache(String, String, String, Object)

displayCacheEntries

public void displayCacheEntries()
Displays the existing cache entries.

Novell exteNd
Director 5.2 API