© 2001 BEA Systems, Inc.

com.beasys.commerce.foundation.cache
Interface Cache

All Superinterfaces:
java.util.Map
All Known Implementing Classes:
CacheImpl

public interface Cache
extends java.util.Map

The main interface for the cache. Provides administrative methods as well as methods to add, lookup, and remove entries from a cache.


Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Method Summary
 void addEntry(java.lang.Object key, java.lang.Object value)
          Deprecated. use put
 void addEntry(java.lang.Object key, java.lang.Object value, long ttl)
          Deprecated. use put
 boolean containsEntry(java.lang.Object key)
          Deprecated. use containsKey
 void disable()
          Disable the cache.
 void enable()
          Enable the cache.
 java.lang.Object fetchEntry(java.lang.Object key)
          Deprecated. use get
 int getEntryCount()
          Deprecated. use size
 long getHitCount()
          Reset the hitCount
 int getHitRate()
          Percent of cache calls which hit - a whole number percentage.
 int getMaxEntries()
          Set the max number of items the cache can have.
 long getMissCount()
          Reset the missCount
 long getTtl()
          Get the time-to-live, in milliseconds, of the cache
 boolean isEnabled()
          Is the cache enabled.
 boolean isFull()
          Is the cache full.
 java.lang.Object put(java.lang.Object key, java.lang.Object value, long ttl)
          Put a value into the cache.
 void remove(java.lang.Object[] keys)
          Remove an array of entries.
 void removeAllEntries()
          Deprecated. use clear
 void removeEntry(java.lang.Object key)
          Deprecated. use remove
 void resetStats()
          Reset hitCount and missCount
 void setMaxEntries(int maxEntries)
          Set the max number of items the cache can have.
 void setTtl(long ttlMillis)
          Set a time-to-live for entries in this cache.
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Method Detail

containsEntry

public boolean containsEntry(java.lang.Object key)
Deprecated. use containsKey

Determine if the cache contains a given entry.
Parameters:
key - the entry to look for
Returns:
boolean, true if the entry exists in the cache

fetchEntry

public java.lang.Object fetchEntry(java.lang.Object key)
Deprecated. use get

Retrieve an entry from the cache
Parameters:
key - the key of the entry to retrieve
Returns:
Object the value associated with the key

addEntry

public void addEntry(java.lang.Object key,
                     java.lang.Object value)
Deprecated. use put

Add entry to the cache.
Parameters:
key - the key of the entry to create
value - the value to associate with the key

addEntry

public void addEntry(java.lang.Object key,
                     java.lang.Object value,
                     long ttl)
Deprecated. use put

Add entry to the cache.
Parameters:
key - the key of the entry to create
value - the value to associate with the key
ttl - a time-to-live value for this entry

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value,
                            long ttl)
Put a value into the cache.
Parameters:
key - the key of the entry to create
value - the value to associate with the key
ttl - a time-to-live value for this entry
Returns:
Object the previous value for the key

removeEntry

public void removeEntry(java.lang.Object key)
Deprecated. use remove

Remove an entry from the cache.
Parameters:
key - the key of the entry to remove

remove

public void remove(java.lang.Object[] keys)
Remove an array of entries.
Parameters:
keys - the keys to remove

isFull

public boolean isFull()
Is the cache full.
Returns:
boolean, true if it is full

isEnabled

public boolean isEnabled()
Is the cache enabled.
Returns:
boolean, true if it is enabled

setTtl

public void setTtl(long ttlMillis)
Set a time-to-live for entries in this cache. This can be overridden for particular entries by using the put method which takes a ttl parameter.
Parameters:
ttlMillis - The time-to-live, in milliseconds, of entries in the cache

getTtl

public long getTtl()
Get the time-to-live, in milliseconds, of the cache
Returns:
the cache's time-to-live value

disable

public void disable()
Disable the cache.

enable

public void enable()
Enable the cache.

resetStats

public void resetStats()
Reset hitCount and missCount

getHitCount

public long getHitCount()
Reset the hitCount

getMissCount

public long getMissCount()
Reset the missCount

getHitRate

public int getHitRate()
Percent of cache calls which hit - a whole number percentage.

setMaxEntries

public void setMaxEntries(int maxEntries)
Set the max number of items the cache can have.
Parameters:
maxEntries - the maximimum size of the cache

getMaxEntries

public int getMaxEntries()
Set the max number of items the cache can have.
Returns:
the maximum size of the cache

getEntryCount

public int getEntryCount()
Deprecated. use size

Get the current number of items the cache has.

removeAllEntries

public void removeAllEntries()
Deprecated. use clear

Flush the whole cache.

© 2001 BEA Systems, Inc.

Copyright © 2001 BEA Systems, Inc. All Rights Reserved