com.hp.hpl.mesa.rdf.jena.rdb
Class SimpleCache

java.lang.Object
  |
  +--com.hp.hpl.mesa.rdf.jena.rdb.SimpleCache
All Implemented Interfaces:
ICache

public class SimpleCache
extends java.lang.Object
implements ICache

Trivial implementation of the generic cache interface used to cache literals and resources. This implementation simple flushes the cache when the threshold limit is exceeded.

Version:
$Revision: 1.1 $ on $Date: 2002/08/09 12:12:50 $
Author:
Dave Reynolds

Constructor Summary
SimpleCache(int threshold)
          Create an empty cache with the given threshold limit.
 
Method Summary
 java.lang.Object get(IDBID id)
          Retreive an object from the cache
 int getLimit()
          Return the current threshold limit for the cache size.
 void put(IDBID id, java.lang.Object val)
          Add an entry to the cache
 void setLimit(int threshold)
          Set a threshold for the cache size in terms of the count of cache entries.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleCache

public SimpleCache(int threshold)
Create an empty cache with the given threshold limit.

Parameters:
threshold - the cache size limit, use 0 for no cache, -1 for unlimited cache growth; any other number indicates the number of cache entries
Method Detail

put

public void put(IDBID id,
                java.lang.Object val)
Add an entry to the cache

Specified by:
put in interface ICache
Parameters:
id - the database ID to be used as an index
val - the literal or resources to be stored

get

public java.lang.Object get(IDBID id)
Retreive an object from the cache

Specified by:
get in interface ICache
Parameters:
id - the database ID of the object to be retrieved
Returns:
the object or null if it is not in the cache

setLimit

public void setLimit(int threshold)
Set a threshold for the cache size in terms of the count of cache entries. For literals a storage limit rather than a count might be more useful but counts are easier, more general and sufficient for the current use.

Specified by:
setLimit in interface ICache
Parameters:
threshold - the cache size limit, use 0 for no cache, -1 for unlimited cache growth; any other number indicates the number of cache entries

getLimit

public int getLimit()
Return the current threshold limit for the cache size.

Specified by:
getLimit in interface ICache


Copyright © 2001 Hewlett-Packard. All Rights Reserved.