com.partnersoft.gadgets
Interface Cache<K,V>

Type Parameters:
K -
V -
All Superinterfaces:
java.lang.Comparable
All Known Implementing Classes:
HashedCache

public interface Cache<K,V>
extends java.lang.Comparable

An object cache, indexed using a key value K, and returning a cached value V.

Copyright 2009 Partner Software, Inc.

Version:
$Id$
Author:
Paul Reavis

Method Summary
 V cachedValueFor(K index)
          Get the object associated with the given index, keeping the returned item in cache subject to capacity and other settings.
 void clear()
          Clears all items from the cache, so that they must be reloaded.
 int getByteSize()
          Gets an estimate of the size of the cached values, in bytes.
 int getCapacity()
          Gets the maximum number of cached values.
 java.lang.String getName()
           
 java.util.List<V> listCachedValues()
          Lists the values currently in cache.
 void setCapacity(int newSize)
          Sets the maximum number of cached values.
 int size()
          Returns the current cache size (number of cached values).
 V uncachedValueFor(K index)
          Get the object associated with the given index, without regard to the cache.
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

getName

java.lang.String getName()

cachedValueFor

V cachedValueFor(K index)
Get the object associated with the given index, keeping the returned item in cache subject to capacity and other settings.


uncachedValueFor

V uncachedValueFor(K index)
Get the object associated with the given index, without regard to the cache. Generally this method is called by the getCached() method on cache misses.


clear

void clear()
Clears all items from the cache, so that they must be reloaded.


listCachedValues

java.util.List<V> listCachedValues()
Lists the values currently in cache.


size

int size()
Returns the current cache size (number of cached values).


getCapacity

int getCapacity()
Gets the maximum number of cached values.


setCapacity

void setCapacity(int newSize)
Sets the maximum number of cached values.


getByteSize

int getByteSize()
Gets an estimate of the size of the cached values, in bytes. If this cannot be determined, a -1 should be returned.