org.apache.commons.cache
Interface Cache

All Superinterfaces:
Serializable
All Known Implementing Classes:
BaseCache, NoOpCache, SimpleCache

public interface Cache
extends Serializable

A Cache defines an API for storing and later retrieving Objects based upon key values.

A Cache supports an event subscription/publication system.

Version:
$Id: Cache.java 155435 2005-02-26 13:17:27Z dirkv $
Author:
Rodney Waldhoff

Method Summary
 void clear()
          Remove all values previously stored.
 void clear(Serializable key)
          Remove any value previously stored under the given key.
 void clearGroup(Serializable group)
          Remove any value previously stored under the given group.
 boolean contains(Serializable key)
          Returns true if I have a value associated with the given key, false otherwise.
 Serializable[] getKeysForGroup(Serializable group)
           
 long getStat(CacheStat stat)
           
 void registerRetrievalListener(RetrievalListener obs)
          Add the given RetrievalListener to my set of RetrievalListeners.
 void registerStorageListener(StorageListener obs)
          Add the given StorageListener to my set of StorageListeners.
 Serializable retrieve(Serializable key)
          Obtain the value previously stored under the given key.
 boolean store(Serializable key, Serializable val, Long expiry, Long cost)
          Store the specified val under the specified key.
 boolean store(Serializable key, Serializable val, Long expiry, Long cost, Serializable group)
          Store the specified val under the specified key and the specified group.
 void unregisterRetrievalListener(RetrievalListener obs)
          Remove the given RetrievalListener from my set of RetrievalListeners.
 void unregisterRetrievalListeners()
          Clear my set of RetrievalListeners.
 void unregisterStorageListener(StorageListener obs)
          Remove the given StorageListener from my set of StorageListeners.
 void unregisterStorageListeners()
          Clear my set of StorageListeners.
 

Method Detail

store

boolean store(Serializable key,
              Serializable val,
              Long expiry,
              Long cost)
Store the specified val under the specified key.

Parameters:
key - the key used to later obtain the val from me, which MUST NOT be null.
val - the val to store, which MUST NOT be null.
expiry - the timestamp at which the given val becomes stale, or null.
cost - the implemenation dependent cost of generating the val, or null.
Returns:
true if the val was stored, false otherwise.

store

boolean store(Serializable key,
              Serializable val,
              Long expiry,
              Long cost,
              Serializable group)
Store the specified val under the specified key and the specified group.

Parameters:
key - the key used to later obtain the val from me, which MUST NOT be null.
group - a meta-key which can be used to clear the object later
val - the val to store, which MUST NOT be null.
expiry - the timestamp at which the given val becomes stale, or null.
cost - the implemenation dependent cost of generating the val, or null.
Returns:
true if the val was stored, false otherwise.

retrieve

Serializable retrieve(Serializable key)
Obtain the value previously stored under the given key.

Parameters:
key - the key which MUST NOT be null.
Returns:
the previously stored value, or null.

getKeysForGroup

Serializable[] getKeysForGroup(Serializable group)

contains

boolean contains(Serializable key)
Returns true if I have a value associated with the given key, false otherwise.

Parameters:
key - the key which MUST NOT be null.
Returns:
true if I have a value associated with the given key, false otherwise.

clear

void clear(Serializable key)
Remove any value previously stored under the given key.

Parameters:
key - the key which MUST NOT be null.

clearGroup

void clearGroup(Serializable group)
Remove any value previously stored under the given group.

Parameters:
group - the group which MUST NOT be null.

clear

void clear()
Remove all values previously stored.


registerStorageListener

void registerStorageListener(StorageListener obs)
Add the given StorageListener to my set of StorageListeners.


unregisterStorageListener

void unregisterStorageListener(StorageListener obs)
Remove the given StorageListener from my set of StorageListeners.


unregisterStorageListeners

void unregisterStorageListeners()
Clear my set of StorageListeners.


registerRetrievalListener

void registerRetrievalListener(RetrievalListener obs)
Add the given RetrievalListener to my set of RetrievalListeners.


unregisterRetrievalListener

void unregisterRetrievalListener(RetrievalListener obs)
Remove the given RetrievalListener from my set of RetrievalListeners.


unregisterRetrievalListeners

void unregisterRetrievalListeners()
Clear my set of RetrievalListeners.


getStat

long getStat(CacheStat stat)
             throws UnsupportedOperationException
Throws:
UnsupportedOperationException


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.