SK.gnome.dwarf.utils.cache
Interface Cache

All Known Implementing Classes:
LRUCache

public interface Cache

Provides interface for a cache.

This class provides interface for a generic cache. The cached objects may optionally implement the Cacheable interface, which provides a basic event handler, informing the objects about their state related to the caching process.


Method Summary
 void clear()
          Removes all objects from the cache.
 java.lang.Object get(java.lang.Object key)
          Returns an object from the cache.
 void put(java.lang.Object key, java.lang.Object obj)
          Puts the object to the cache.
 java.lang.Object remove(java.lang.Object key)
          Removes an object from the cache.
 

Method Detail

put

public void put(java.lang.Object key,
                java.lang.Object obj)
Puts the object to the cache.

If an object implementing the Cacheable interface is being added to the cache, the Cacheable.handleCacheEvent(Cacheable.CacheEvent) method must be invoked on it with the Cacheable.CacheEvent.ADDED value.

If an object implementing the Cacheable interface must be removed from the cache prior to inserting the new one, the Cacheable.handleCacheEvent(Cacheable.CacheEvent) method must be invoked on it with the Cacheable.CacheEvent.INVALIDATED value.

Parameters:
key - the key
obj - the cached object

get

public java.lang.Object get(java.lang.Object key)
Returns an object from the cache.

The object still remains in the cache.

Parameters:
key - the key
Returns:
the cached object or null if no object referenced by the given key was found

remove

public java.lang.Object remove(java.lang.Object key)
Removes an object from the cache.

If an object implementing the Cacheable interface is being removed from the cache, the Cacheable.handleCacheEvent(Cacheable.CacheEvent) method must be invoked on it with the Cacheable.CacheEvent.REMOVED value.

Parameters:
key - the key
Returns:
the cached object or null if no object referenced by the given key was found

clear

public void clear()
Removes all objects from the cache.

If an object implementing the Cacheable interface is being removed from the cache, the Cacheable.handleCacheEvent(Cacheable.CacheEvent) method must be invoked on it with the Cacheable.CacheEvent.INVALIDATED value.



Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.