org.hibernate.cache
Interface Cache

All Known Subinterfaces:
OptimisticCache
All Known Implementing Classes:
EhCache, HashtableCache, OptimisticTreeCache, OSCache, SwarmCache, TreeCache

public interface Cache

Implementors define a caching algorithm. All implementors must be threadsafe.


Method Summary
 void clear()
          Clear the cache
 void destroy()
          Clean up
 Object get(Object key)
          Get an item from the cache, nontransactionally
 long getElementCountInMemory()
          The count of entries currently contained in the regions in-memory store.
 long getElementCountOnDisk()
          The count of entries currently contained in the regions disk store.
 String getRegionName()
          Get the name of the cache region
 long getSizeInMemory()
          The number of bytes is this cache region currently consuming in memory.
 int getTimeout()
          Get a reasonable "lock timeout"
 void lock(Object key)
          If this is a clustered cache, lock the item
 long nextTimestamp()
          Generate a timestamp
 void put(Object key, Object value)
          Add an item to the cache, nontransactionally, with failfast semantics
 Object read(Object key)
          Get an item from the cache
 void remove(Object key)
          Remove an item from the cache
 Map toMap()
          optional operation
 void unlock(Object key)
          If this is a clustered cache, unlock the item
 void update(Object key, Object value)
          Add an item to the cache
 

Method Detail

read

Object read(Object key)
            throws CacheException
Get an item from the cache

Parameters:
key -
Returns:
the cached object or null
Throws:
CacheException

get

Object get(Object key)
           throws CacheException
Get an item from the cache, nontransactionally

Parameters:
key -
Returns:
the cached object or null
Throws:
CacheException

put

void put(Object key,
         Object value)
         throws CacheException
Add an item to the cache, nontransactionally, with failfast semantics

Parameters:
key -
value -
Throws:
CacheException

update

void update(Object key,
            Object value)
            throws CacheException
Add an item to the cache

Parameters:
key -
value -
Throws:
CacheException

remove

void remove(Object key)
            throws CacheException
Remove an item from the cache

Throws:
CacheException

clear

void clear()
           throws CacheException
Clear the cache

Throws:
CacheException

destroy

void destroy()
             throws CacheException
Clean up

Throws:
CacheException

lock

void lock(Object key)
          throws CacheException
If this is a clustered cache, lock the item

Throws:
CacheException

unlock

void unlock(Object key)
            throws CacheException
If this is a clustered cache, unlock the item

Throws:
CacheException

nextTimestamp

long nextTimestamp()
Generate a timestamp


getTimeout

int getTimeout()
Get a reasonable "lock timeout"


getRegionName

String getRegionName()
Get the name of the cache region


getSizeInMemory

long getSizeInMemory()
The number of bytes is this cache region currently consuming in memory.

Returns:
The number of bytes consumed by this region; -1 if unknown or unsupported.

getElementCountInMemory

long getElementCountInMemory()
The count of entries currently contained in the regions in-memory store.

Returns:
The count of entries in memory; -1 if unknown or unsupported.

getElementCountOnDisk

long getElementCountOnDisk()
The count of entries currently contained in the regions disk store.

Returns:
The count of entries on disk; -1 if unknown or unsupported.

toMap

Map toMap()
optional operation