Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

WebLogic Server 5.1.0sp9 API Reference

## weblogic.security.acl
Class TTLCache

    java.lang.Object
      |
      +--weblogic.security.acl.TTLCache

public class TTLCache
extends java.lang.Object

Fixed-size pseudo-LRU cache with per-entry TTL attributes. This cache maps keys to values in the usual way, and associates a time-to-live (TTL) value with each map entry.

If the cache is full when an insertion is performed, an approximation to the least-recently-used (LRU) entry is evicted to make room for the new entry.

Entries that become stale, because they have exceeded their tiem-to-live values, are removed from the cache.

Keys are considered immutable; if you change a key after adding it to a cache, the mapping will be lost.

Author:
  Copyright © 2001 BEA Systems, Inc. All Rights Reserved.

Constructor Summary
`TTLCache(int buckets, int capacity, long ttl)` Construct a new cache.
`TTLCache(int buckets, long ttl)` Construct a new cache.

Method Summary
`void` | `cleanup()` Force the cache to be cleaned.
`void` | `clear()` Clear the cache.
`boolean` | `containsKey(java.lang.Object key)`
`java.lang.Object` | `get(java.lang.Object key)` Return the value associated with the given key, or null if none.
`weblogic.logging.LogOutputStream` | `getDebugLog()`
`double` | `getHitRate()` The hit rate for lookups performed since this cache was constructed or last cleared.
`int` | `getInsertions()` The number of insertions performed since this cache was constructed or last cleared.
`int` | `getLookups()` The number of lookups performed since this cache was constructed or last cleared.
`double` | `getLRUEvictionRate()` The LRU eviction rate for insertions performed since this cache was constructed or last cleared.
`double` | `getStaleEvictionRate()` The stale eviction rate for insertions performed since this cache was constructed or last cleared.
`boolean` | `isEmpty()` Indicate whether this table is empty.
`java.lang.Object` | `put(java.lang.Object keyValue)` Insert a new entry into the cache.
`java.lang.Object` | `put(java.lang.Object key, java.lang.Object value)` Insert a new entry into the cache.
`java.lang.Object` | `remove(java.lang.Object key)` Remove the mapping for the given key from the cache.
`void` | `setDebugLog(weblogic.logging.LogOutputStream debug)`
`int` | `size()` Return an approximate indication of the size of this table.

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

Constructor Detail

### TTLCache

    public TTLCache(int buckets,
                    long ttl)

  Construct a new cache. The number of `buckets` must be specified; the overall capacity will be six times the number of buckets. Each entry will live no longer than `ttl` milliseconds.

  For best performance, the number of the buckets should be prime.

  Parameters:
    `buckets` - number of buckets
    `ttl` - time-to-live for entries, in milliseconds

### TTLCache

    public TTLCache(int buckets,
                    int capacity,
                    long ttl)

  Construct a new cache. The number of `buckets` must be specified, as must the overall `capacity` (which must be greater than the number of buckets). Each entry will live no longer than `ttl` milliseconds.

  For best performance, the number of buckets should be prime, and the capacity of the cache should be roughly a small multiple (between 4 and 10) of the number of buckets.

  Parameters:
    `buckets` - number of buckets
    `capacity` - capacity of the cache
    `ttl` - time-to-live for entries, in milliseconds

Method Detail

### put

    public java.lang.Object put(java.lang.Object key,
                                java.lang.Object value)

  Insert a new entry into the cache. If another `value` was already present for the same `key` in the map, the old value may (but is not guaranteed) be returned.

  Parameters:
    `key` - (may not be null)
    `value` - (may not be null)
  Returns:
    previous value for the given key, if found

### put

    public java.lang.Object put(java.lang.Object keyValue)

  Insert a new entry into the cache. This entry maps the key to itself. If another `value` was already present for the same `key` in the map, the old value may (but is not guaranteed) be returned.

  Parameters:
    `keyValue` - key and value (may not be null)
  Returns:
    previous value for the given key, if found

### get

    public java.lang.Object get(java.lang.Object key)

  Return the value associated with the given key, or null if none.

  Returns:
    value, or null

### remove

    public java.lang.Object remove(java.lang.Object key)

  Remove the mapping for the given key from the cache. If the mapping existed and was not stale, its old value is returned, otherwise null.

  Parameters:
    `key` - the key of the mapping to remove
  Returns:
    old value

### clear

    public void clear()

  Clear the cache. All statistics are also reset.

### cleanup

    public void cleanup()

  Force the cache to be cleaned. This forcibly evicts any stale entries that have not yet been automatically cleaned out.

### size

    public int size()

  Return an approximate indication of the size of this table. This value will include any stale entries in the table, and so may not be accurate.

### isEmpty

    public boolean isEmpty()

  Indicate whether this table is empty.

### containsKey

    public boolean containsKey(java.lang.Object key)

### setDebugLog

    public void setDebugLog(weblogic.logging.LogOutputStream debug)

### getDebugLog

    public weblogic.logging.LogOutputStream getDebugLog()

### getLookups

    public int getLookups()

  The number of lookups performed since this cache was constructed or last cleared.

### getHitRate

    public double getHitRate()

  The hit rate for lookups performed since this cache was constructed or last cleared. This is a value between 0 and 1; higher values are better. If your hit rate seems too low, try raising your TTL or changing your cache size.

  If this method is called before any lookups have been performed, a divide-by-zero exception will result.

### getInsertions

    public int getInsertions()

  The number of insertions performed since this cache was constructed or last cleared. This does not have any correspondence to the number of entries currently in the cache.

### getStaleEvictionRate

    public double getStaleEvictionRate()

  The stale eviction rate for insertions performed since this cache was constructed or last cleared. This is a value between 0 and 1. A stale eviction indicates that an existing entry was evicted from the cache either because its TTL expired. A high stale eviction rate is not necessarily bad.

  If this method is called before any lookups have been performed, a divide-by-zero exception will result.

### getLRUEvictionRate

    public double getLRUEvictionRate()

  The LRU eviction rate for insertions performed since this cache was constructed or last cleared. This is a value between 0 and 1. An LRU eviction indicates that an existing entry was evicted from the cache because the cache was full. A high LRU eviction rate indicates that the cache size should be increased.

  If this method is called before any lookups have been performed, a divide-by-zero exception will result.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://www.weblogic.com/docs51
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD