JBoss API: Interface CachePolicy

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.util
Interface CachePolicy

All Superinterfaces:
  Service

All Known Subinterfaces:
  EnterpriseContextCachePolicy

All Known Implementing Classes:
  LRUCachePolicy, TimedCachePolicy

public interface CachePolicy
extends Service

Interface that specifies a policy for caches.

Implementation classes can implement a LRU policy, a random one, a MRU one, or any other suitable policy.

Version:
  $Revision: 1.2 $
Author:
  Simone Bordet (simone.bordet@compaq.com)

Method Summary
`void` | `flush()` Flushes the cached objects from the cache.
`java.lang.Object` | `get(java.lang.Object key)` Returns the object paired with the specified key if it's present in the cache, otherwise must return null.
`void` | `insert(java.lang.Object key, java.lang.Object object)` Inserts the specified object into the cache following the implemented policy.
`java.lang.Object` | `peek(java.lang.Object key)` Returns the object paired with the specified key if it's present in the cache, otherwise must return null.
`void` | `remove(java.lang.Object key)` Remove the cached object paired with the specified key.

Methods inherited from interface org.jboss.util.Service
`destroy, init, start, stop`

Method Detail

### get

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

  Returns the object paired with the specified key if it's present in the cache, otherwise must return null.
  Implementations of this method must have complexity of order O(1). Differently from `peek(java.lang.Object)` this method not only return whether the object is present in the cache or not, but also applies the implemented policy that will "refresh" the cached object in the cache, because this cached object was really requested.
  Parameters:
    `key` - the key paired with the object
  See Also:
    `peek(java.lang.Object)`

### peek

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

  Returns the object paired with the specified key if it's present in the cache, otherwise must return null.
  Implementations of this method must have complexity of order O(1). This method should not apply the implemented caching policy to the object paired with the given key, so that a client can query if an object is cached without "refresh" its cache status. Real requests for the object must be done using `get(java.lang.Object)`.
  Parameters:
    `key` - the key paired with the object
  See Also:
    `get(java.lang.Object)`

### insert

    public void insert(java.lang.Object key,
                       java.lang.Object object)

  Inserts the specified object into the cache following the implemented policy.
  Implementations of this method must have complexity of order O(1).
  Parameters:
    `key` - the key paired with the object
    `object` - the object to cache
  See Also:
    `remove(java.lang.Object)`

### remove

    public void remove(java.lang.Object key)

  Remove the cached object paired with the specified key.
  Implementations of this method must have complexity of order O(1).
  Parameters:
    `key` - the key paired with the object
  See Also:
    `insert(java.lang.Object, java.lang.Object)`

### flush

    public void flush()

  Flushes the cached objects from the cache.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000 The JBoss Organization. All Rights Reserved.