com.bankframe.services.cache
Class LruCachePolicy

java.lang.Object
  extended bycom.bankframe.services.cache.LruCachePolicy
All Implemented Interfaces:
CachePolicy, ConfigurableCachePolicy

public class LruCachePolicy
extends java.lang.Object
implements ConfigurableCachePolicy

This class implements a Least Recently Used cache policy. Whenever the number of Cache elements grows to more than the value of maxSize, the least recently used entries will be removed. This policy supports the following configurable properties:

Author:
Engineering

Constructor Summary
LruCachePolicy()
          This Constructor This creates a default instance of the policy where maxSize has a value of 100 and the thrash amount is set to zero (i.e only enought elements will be removed from the cache to bring it back to the max size).
LruCachePolicy(int maxSize)
          This constructor creates a Lru policy with the given maximum size and a 0 thrash value
LruCachePolicy(int maxSize, int thrashAmount)
          This constructor creates a Lru policy with the given maximum size and the given thrash value
 
Method Summary
 java.util.Set cleanup()
          This method returns a set containing the keys of values that have expired.
 void configure(BankFrameResource config)
           
 int getMaxSize()
          This method gets the maximum size defined by this policy
 int getThrashAmount()
           
 boolean isCacheEntryValid(java.lang.Object key, java.lang.Object value)
          This method determines if the specified entry should be removed from the cache
 void remove(java.lang.Object key)
          This method signals the entry has been removed from the cache
 void remove(java.util.Set keySet)
          This method signals the set of entries has been removed from the cache
 void removeAll()
          This method signals that all entries have been removed from the cache
 void setMaxSize(int maxSize)
          This method sets the maximum size of the Cache.
 void setThrashAmount(int i)
           
 void updateCacheEntries(java.util.Map values)
          This method updates all the specified values
 void updateCacheEntry(java.lang.Object key, java.lang.Object value)
          This method updates the last access time for the specified entry
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LruCachePolicy

public LruCachePolicy()
This Constructor This creates a default instance of the policy where maxSize has a value of 100 and the thrash amount is set to zero (i.e only enought elements will be removed from the cache to bring it back to the max size).


LruCachePolicy

public LruCachePolicy(int maxSize)
This constructor creates a Lru policy with the given maximum size and a 0 thrash value

Parameters:
maxSize - The maximum number of elements permitted in the Cache

LruCachePolicy

public LruCachePolicy(int maxSize,
                      int thrashAmount)
This constructor creates a Lru policy with the given maximum size and the given thrash value

Parameters:
maxSize - The maximum number of elements permitted in the Cache
thrashAmount - the thrashAmount to use
Method Detail

cleanup

public java.util.Set cleanup()
Description copied from interface: CachePolicy
This method returns a set containing the keys of values that have expired. If this method returns an empty set then there are no values to be removed. If this method returns a null value, then all values have expired

Specified by:
cleanup in interface CachePolicy
See Also:
CachePolicy.cleanup()

getMaxSize

public int getMaxSize()
This method gets the maximum size defined by this policy

Returns:
the maximum number of elements allowed by this policy

isCacheEntryValid

public boolean isCacheEntryValid(java.lang.Object key,
                                 java.lang.Object value)
Description copied from interface: CachePolicy
This method determines if the specified entry should be removed from the cache

Specified by:
isCacheEntryValid in interface CachePolicy
See Also:
CachePolicy.isCacheEntryValid(Object, Object)

remove

public void remove(java.lang.Object key)
Description copied from interface: CachePolicy
This method signals the entry has been removed from the cache

Specified by:
remove in interface CachePolicy
See Also:
CachePolicy.remove(Object)

remove

public void remove(java.util.Set keySet)
Description copied from interface: CachePolicy
This method signals the set of entries has been removed from the cache

Specified by:
remove in interface CachePolicy
See Also:
CachePolicy.remove(Set)

removeAll

public void removeAll()
Description copied from interface: CachePolicy
This method signals that all entries have been removed from the cache

Specified by:
removeAll in interface CachePolicy
See Also:
CachePolicy.removeAll()

setMaxSize

public void setMaxSize(int maxSize)
This method sets the maximum size of the Cache. Note that calling this method does not have an immediate effect, the change will only be applied on the next call to cleanup().

Parameters:
maxSize - the new maximum size allowed by this policy

updateCacheEntries

public void updateCacheEntries(java.util.Map values)
Description copied from interface: CachePolicy
This method updates all the specified values

Specified by:
updateCacheEntries in interface CachePolicy
See Also:
CachePolicy.updateCacheEntries(Map)

updateCacheEntry

public void updateCacheEntry(java.lang.Object key,
                             java.lang.Object value)
Description copied from interface: CachePolicy
This method updates the last access time for the specified entry

Specified by:
updateCacheEntry in interface CachePolicy
See Also:
CachePolicy.updateCacheEntry(Object, Object)

configure

public void configure(BankFrameResource config)
Specified by:
configure in interface ConfigurableCachePolicy

getThrashAmount

public int getThrashAmount()
Returns:

setThrashAmount

public void setThrashAmount(int i)
Parameters:
i -


Copyright © 2004 Siebel Systems, Inc. All rights reserved.