common-util

local.tomas.util.cache
Interface CacheBackend<K,V>

Type Parameters:
K - type of object key
V - type of cache objects

public interface CacheBackend<K,V>

Interface for cache backends.

Author:
tomas.teubner

Method Summary
 V create(K key, Date d)
          Create new object in backend.
 CacheItem<K,V> get(K key)
          Get cache item from backend.
 Iterator<CacheItem<K,V>> load()
          Get iterator over saved items.
 void put(K key, V value, Date d)
          Save cache item in backend.
 void remove(K key)
          Remove object from backend.
 void unload(K key, Date d)
           
 

Method Detail

get

CacheItem<K,V> get(K key)
                   throws CacheException
Get cache item from backend.

Parameters:
key - object key
Returns:
cache item
Throws:
CacheException - on backend exceptions

put

void put(K key,
         V value,
         Date d)
         throws CacheException
Save cache item in backend.

Parameters:
key - object key
value - object
d - date of last access
Throws:
CacheException - on backend exceptions

create

V create(K key,
         Date d)
         throws CacheException
Create new object in backend.

Parameters:
key - object key
d - date of last access
Returns:
new object
Throws:
CacheException - on backend exceptions

remove

void remove(K key)
            throws CacheException
Remove object from backend.

Parameters:
key - object key
Throws:
CacheException - on backend exceptions

load

Iterator<CacheItem<K,V>> load()
                              throws CacheException
Get iterator over saved items.

Returns:
iterator over saved cache items
Throws:
CacheException - on backen exceptions

unload

void unload(K key,
            Date d)
            throws CacheException
Throws:
CacheException

common-util

Copyright © 2005-2007 Tomas Teubner. All Rights Reserved.