org.apache.avalon.excalibur.cache
Interface Cache

All Superinterfaces:
org.apache.avalon.framework.component.Component
All Known Implementing Classes:
AbstractCache, SynchronizedCache, ValidatingCache

public interface Cache
extends org.apache.avalon.framework.component.Component

This is a cache that caches objects for reuse. Key is must not null. Value is possible to null.

Author:
Eung-ju Park

Method Summary
 void addListener(CacheListener listener)
          Add listener.
 int capacity()
          Return capacity of cache.
 void clear()
          Clear cache.
 boolean containsKey(java.lang.Object key)
           
 java.lang.Object get(java.lang.Object key)
          Get an item from the cache.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Puts a new item in the cache.
 java.lang.Object remove(java.lang.Object key)
          Removes an item from the cache.
 void removeListener(CacheListener listener)
          Remove listener.
 int size()
          Return size of cache.
 

Method Detail

addListener

public void addListener(CacheListener listener)
Add listener.
Parameters:
listener - listener instance to add

removeListener

public void removeListener(CacheListener listener)
Remove listener.
Parameters:
listener - listener instance to remove

capacity

public int capacity()
Return capacity of cache.
Returns:
capacity of cache

size

public int size()
Return size of cache.
Returns:
the number of key-value mappings in this cache.

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Puts a new item in the cache. If the cache is full, remove the selected item.
Parameters:
key - key for the item
value - item
Returns:
old value. null if old value not exists.

get

public java.lang.Object get(java.lang.Object key)
Get an item from the cache.
Parameters:
key - key to lookup the item
Returns:
the matching object in the cache. null if item not exists.

remove

public java.lang.Object remove(java.lang.Object key)
Removes an item from the cache.
Parameters:
key - key to remove
Returns:
the value removed. null if old value not exists.

containsKey

public boolean containsKey(java.lang.Object key)
Parameters:
key -  
Returns:
true if matching item in the cache

clear

public void clear()
Clear cache.


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.