## com.sun.appserv.util.cache
Class BoundedMultiLruCache

    java.lang.Object
      com.sun.appserv.util.cache.BaseCache
          com.sun.appserv.util.cache.MultiLruCache
              com.sun.appserv.util.cache.BoundedMultiLruCache

All Implemented Interfaces:
  Cache

    public class BoundedMultiLruCache

extends MultiLruCache

MultiLruCache -- in-memory bounded LRU cache with multiple LRU lists Underlying Hashtable is made into logical segments, with each segment having its own LRU list.

Nested Class Summary

Nested classes/interfaces inherited from class com.sun.appserv.util.cache.BaseCache
`BaseCache.CacheItem`

Field Summary
`protected long` `currentSize`
`protected long` `maxSize`

Fields inherited from class com.sun.appserv.util.cache.MultiLruCache
`DEFAULT_HASHTABLE_SEGMENT_SIZE, listsLength, LRU_HEAD, LRU_TAIL`

Fields inherited from class com.sun.appserv.util.cache.BaseCache
`_rb, bucketLocks, buckets, entryCount, listeners, maxBuckets, refreshFlags, threshold`

Constructor Summary
`BoundedMultiLruCache()`

Method Summary
`protected void` `decrementCurrentSize(int size)`
`Object` `getStatByName(String key)` get the desired statistic counter
`Map` `getStats()` get the stats snapshot
`protected void` `incrementCurrentSize(int size)` synchronized counter updates
`void` `init(int maxCapacity, Properties props)` initialize the LRU cache
`protected boolean` `isThresholdReached()` has cache reached its threshold
`protected BaseCache.CacheItem` `itemAdded(BaseCache.CacheItem item)` this item is just added to the cache
`protected void` `itemRefreshed(BaseCache.CacheItem item, int oldSize)` item value has been refreshed
`protected void` `itemRemoved(BaseCache.CacheItem item)` item value has been removed from the cache

Methods inherited from class com.sun.appserv.util.cache.MultiLruCache
`createItem, handleOverflow, incrementTrimIndex, itemAccessed, trimLru`

Methods inherited from class com.sun.appserv.util.cache.BaseCache

`_put, _remove, _removeItem, add, add, addCacheListener, clear, clearStats, contains, decrementEntryCount, destroy, elements, eq, get, get, getAll, getEntryCount, getIndex, getIndex, hash, incrementAddCount, incrementEntryCount, incrementHitCount, incrementMissCount, incrementOverflowCount, incrementRefreshCount, incrementRemovalCount, init, isEmpty, keys, loadValue, notifyRefresh, put, put, remove, remove, remove, removeAll, trimExpiredEntries, trimItem, values, waitRefresh`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### maxSize

    protected long maxSize

### currentSize

    protected long currentSize

Constructor Detail

### BoundedMultiLruCache

    public BoundedMultiLruCache()

Method Detail

### init

    public void init(int maxCapacity,
                     Properties props)
              throws Exception

  initialize the LRU cache

  Specified by:
    `init` in interface `Cache`
  Overrides:
    `init` in class `MultiLruCache`
  Parameters:
    `maxCapacity` - maximum number of entries this cache may hold
    `props` - opaque list of properties for a given cache implementation
  Throws:
    `Exception`

### itemAdded

    protected BaseCache.CacheItem itemAdded(BaseCache.CacheItem item)

  this item is just added to the cache

  Overrides:
    `itemAdded` in class `MultiLruCache`
  Parameters:
    `item` - `CacheItem` that was created
  Returns:
    a overflow item; may be null Cache bucket is already synchronized by the caller

### itemRefreshed

    protected void itemRefreshed(BaseCache.CacheItem item,
                                 int oldSize)

  item value has been refreshed

  Overrides:
    `itemRefreshed` in class `MultiLruCache`
  Parameters:
    `item` - `CacheItem` that was refreshed
    `oldSize` - size of the previous value that was refreshed Cache bucket is already synchronized by the caller

### itemRemoved

    protected void itemRemoved(BaseCache.CacheItem item)

  item value has been removed from the cache

  Overrides:
    `itemRemoved` in class `MultiLruCache`
  Parameters:
    `item` - `CacheItem` that was just removed Cache bucket is already synchronized by the caller

### isThresholdReached

    protected boolean isThresholdReached()

  has cache reached its threshold

  Overrides:
    `isThresholdReached` in class `BaseCache`
  Returns:
    true when the cache reached its threshold

### incrementCurrentSize

    protected final void incrementCurrentSize(int size)

  synchronized counter updates

### decrementCurrentSize

    protected final void decrementCurrentSize(int size)

### getStatByName

    public Object getStatByName(String key)

  get the desired statistic counter

  Specified by:
    `getStatByName` in interface `Cache`
  Overrides:
    `getStatByName` in class `MultiLruCache`
  Parameters:
    `key` - to corresponding stat
  Returns:
    an Object corresponding to the stat See also: Constant.java for the key

### getStats

    public Map getStats()

  Description copied from class: `MultiLruCache`
  get the stats snapshot

  Specified by:
    `getStats` in interface `Cache`
  Overrides:
    `getStats` in class `MultiLruCache`
  Returns:
    a Map of stats See also: Constant.java for the keys

Copyright © 2008 Mort Bay Consulting. All Rights Reserved.