org.figure8.join.services.cache
Interface Cache

All Known Implementing Classes:
EhCache

public interface Cache

Interface defining a standard basic cache. Implementors may encapsulate existing Cache providers (EHCache, JBossTree, ...). Join Caches restrict keys and elements to be Serializable : this should help if wanting to have clustered and distributed caches.

Version:
$Revision: 1.2 $
Author:
Laurent Broudoux
See Also:
Serializable

Method Summary
 void cleanUp()
          Remove all elements from this cache and the cache itself.
 void clear()
          Remove all elements from this cache but leave it in a usable state
 java.io.Serializable get(java.io.Serializable key)
          Get the value of a cache element which matches the key
 java.util.List getElements()
          Get all the elements of this cache.
 java.lang.String getKey()
          Get the key this cache is registred within CacheManager
 void put(java.io.Serializable key, java.io.Serializable value)
          Puts an object into the cache
 void remove(java.io.Serializable key)
          Remove an object from the cache
 

Method Detail

getKey

java.lang.String getKey()
Get the key this cache is registred within CacheManager

Returns:
This cache key (ie. its name)

getElements

java.util.List getElements()
Get all the elements of this cache. This method returns a list that do not prevent from having duplicates !

Returns:
A List of the cache elements

get

java.io.Serializable get(java.io.Serializable key)
Get the value of a cache element which matches the key

Parameters:
key - The key of the element to return
Returns:
The value placed into the cache with an earlier put, or null if not found or expired

put

void put(java.io.Serializable key,
         java.io.Serializable value)
         throws CacheException
Puts an object into the cache

Parameters:
key - a serializable key
value - a serializable value
Throws:
CacheException - if object cannot be put into cache

remove

void remove(java.io.Serializable key)
            throws CacheException
Remove an object from the cache

Parameters:
key - a serializable key
Throws:
CacheException - if something went wrong during removal

clear

void clear()
           throws CacheException
Remove all elements from this cache but leave it in a usable state

Throws:
CacheException - if cache cannot be cleared

cleanUp

void cleanUp()
             throws CacheException
Remove all elements from this cache and the cache itself. It is no longer usable. CacheManager should no longer offer access to this cache until explicit cache re-creation.

Throws:
CacheException - if cache cannot be cleaned up


Copyright © 2005-2008 Join. All Rights Reserved.