Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.1.6 generated on August 25 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## kodo.datacache
Class QueryCacheImpl

    java.lang.Object
      |
      +--kodo.datacache.QueryCacheImpl

All Implemented Interfaces:
  ClassChangeListener, com.solarmetric.util.Closeable, Configurable, QueryCache

public class QueryCacheImpl
extends Object
implements QueryCache, Configurable, ClassChangeListener

Default query cache implementation.

Field Summary
`protected Configuration` | `_conf`

Constructor Summary
`QueryCacheImpl()`

Method Summary
`void` | `classesChanged(Collection classes)` Invoked when objects of the types in the `classes` set have been changed.
`void` | `clear()` Remove all data from this cache.
`void` | `close()` Close this cache, dropping all hard references and releasing any resources that this cache maintains.
`void` | `endConfiguration()` Invoked upon completion of bean property configuration for this object.
`List` | `get(QueryKey qk)` Return a list of OIDs for the given query key.
`CacheMap` | `getCacheMap()` Returns the underlying `CacheMap` that this `QueryCacheImpl` is using.
`int` | `getCacheSize()` Returns the maximum number of unpinned objects to keep hard references to.
`QueryKeyExpirationListener` | `getExpirationListener()` Returns this query cache's expiration listener.
`int` | `getSoftReferenceSize()` Returns the maximum number of unpinned objects to keep soft references to.
`protected CacheMap` | `newCacheMap()` Returns a new `CacheMap` for use as the underlying data cache.
`void` | `notifyChangedClasses(Collection classes)` Tells the cache that all the classes in the `classes` set have been changed.
`boolean` | `pin(QueryKey qk)` Pin the value stored under `qk` into the cache.
`List` | `put(QueryKey qk, List oids)` Set the list of OIDs for the given query key.
`void` | `registerListener(ClassChangeListener ccl)` Register `ccl` with this cache.
`List` | `remove(QueryKey qk)` Remove the value stored under the given query key.
`void` | `removeListener(ClassChangeListener ccl)` Unregister `ccl` from the set of listeners managed by this cache.
`void` | `setCacheSize(int size)` Sets the maximum number of unpinned objects to keep hard references to.
`void` | `setConfiguration(Configuration conf)` Invoked prior to setting bean properties.
`void` | `setSoftReferenceSize(int size)` Sets the maximum number of unpinned objects to keep soft references to.
`void` | `startConfiguration()` Invoked before bean property configuration is begun on this object.
`boolean` | `unpin(QueryKey qk)` Unpin the value stored under `key` into the cache.

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

Field Detail

### _conf

    protected Configuration _conf

Constructor Detail

### QueryCacheImpl

    public QueryCacheImpl()

Method Detail

### getCacheMap

    public CacheMap getCacheMap()

  Returns the underlying `CacheMap` that this `QueryCacheImpl` is using. This is not an unmodifiable view on the map, so care should be taken with this reference. Implementations should probably not mess with the contents of the cache, but should only use this reference to obtain cache metrics. Additionally, this map may contain expired data. Removal of timed-out data is done in a lazy fashion, so the actual size of the map may be greater than the number of non-expired query results in cache.

  Methods that manipulate the cache map should synchronize on the map.

### setCacheSize

    public void setCacheSize(int size)

  Sets the maximum number of unpinned objects to keep hard references to. If the map contains more unpinned objects than `size`, then this method will result in the cache flushing old values.

### getCacheSize

    public int getCacheSize()

  Returns the maximum number of unpinned objects to keep hard references to.

### setSoftReferenceSize

    public void setSoftReferenceSize(int size)

  Sets the maximum number of unpinned objects to keep soft references to. If the map contains more soft references than `size`, then this method will result in the cache flushing values.

### getSoftReferenceSize

    public int getSoftReferenceSize()

  Returns the maximum number of unpinned objects to keep soft references to. Defaults to `-1`.

### newCacheMap

    protected CacheMap newCacheMap()

  Returns a new `CacheMap` for use as the underlying data cache. This implementation returns a `CacheMap`. To implement a more sophisticated caching strategy, override this method to return a subclass of `CacheMap`.

### notifyChangedClasses

    public void notifyChangedClasses(Collection classes)

  Description copied from interface: `QueryCache`

  Tells the cache that all the classes in the `classes` set have been changed. This could mean that items have been updated, deleted, or added. This limits the `QueryCache` to only be able to invalidate cached queries -- because the cache is not notified of actual changes, it cannot recompute query results.

  After this method is invoked, all cached results that correspond to queries that use one of the classes in `classes` will be dropped.

  Specified by:
    `notifyChangedClasses` in interface `QueryCache`
  Following copied from interface: `kodo.datacache.QueryCache`
  Parameters:
    `classes` - a set of `Class` objects that correspond to instances that have changed

### registerListener

    public void registerListener(ClassChangeListener ccl)

  Description copied from interface: `QueryCache`
  Register `ccl` with this cache.
  Specified by:
    `registerListener` in interface `QueryCache`

### removeListener

    public void removeListener(ClassChangeListener ccl)

  Description copied from interface: `QueryCache`
  Unregister `ccl` from the set of listeners managed by this cache.
  Specified by:
    `removeListener` in interface `QueryCache`

### classesChanged

    public void classesChanged(Collection classes)

  Description copied from interface: `ClassChangeListener`

  Invoked when objects of the types in the `classes` set have been changed. This could mean that items have been updated, deleted, or added.

  Specified by:
    `classesChanged` in interface `ClassChangeListener`
  Following copied from interface: `kodo.datacache.ClassChangeListener`
  Parameters:
    `classes` - a set of `Class` objects that correspond to instances that have changed

### get

    public List get(QueryKey qk)

  Description copied from interface: `QueryCache`

  Return a list of OIDs for the given query key. This is an unmodifiable list.

  Specified by:
    `get` in interface `QueryCache`
  Following copied from interface: `kodo.datacache.QueryCache`
  Returns:
    the query results matching the given key, or null if none.

### put

    public List put(QueryKey qk,
                    List oids)

  Description copied from interface: `QueryCache`

  Set the list of OIDs for the given query key. A reference to the given list will be stored in the query cache, so the list should not be modified after invoking this method.

  Specified by:
    `put` in interface `QueryCache`
  Following copied from interface: `kodo.datacache.QueryCache`
  Returns:
    The previously cached value, or `null` if the key was not previously cached. See `Map.put(java.lang.Object, java.lang.Object)` for more information.

### remove

    public List remove(QueryKey qk)

  Description copied from interface: `QueryCache`

  Remove the value stored under the given query key.

  This method is typically not invoked directly from outside the `QueryCache` class. Instead, the cache should be updated by invoking `QueryCache.notifyChangedClasses(java.util.Collection)`, which will result in all queries that may be invalid being dropped.

  Specified by:
    `remove` in interface `QueryCache`
  Following copied from interface: `kodo.datacache.QueryCache`
  Returns:
    The previously cached value, or `null` if the key was not previously cached. See `Map.remove(java.lang.Object)` for more information.

### clear

    public void clear()

  Description copied from interface: `QueryCache`

  Remove all data from this cache.

  Specified by:
    `clear` in interface `QueryCache`

### pin

    public boolean pin(QueryKey qk)

  Description copied from interface: `QueryCache`
  Pin the value stored under `qk` into the cache. This method guarantees that `qk`'s value will not be expired if the cache exceeds its capacity. It causes this data to be ignored when determining whether or not the cache is full, effectively increasing the total amount of data stored in the cache. This method does not affect the behavior of `QueryCache.remove(kodo.datacache.QueryKey)` or `QueryCache.notifyChangedClasses(java.util.Collection)`.
  Specified by:
    `pin` in interface `QueryCache`
  Following copied from interface: `kodo.datacache.QueryCache`
  Returns:
    `true` if `key`'s value was pinned into the cache; `false` if the key is not in the cache.

### unpin

    public boolean unpin(QueryKey qk)

  Description copied from interface: `QueryCache`
  Unpin the value stored under `key` into the cache. This method reverses a previous invocation of `QueryCache.pin(kodo.datacache.QueryKey)`. This method does not remove anything from the cache; it merely makes `key`'s value a candidate for flushing from the cache.
  Specified by:
    `unpin` in interface `QueryCache`
  Following copied from interface: `kodo.datacache.QueryCache`
  Returns:
    `true` if `key`'s value was unpinned from the cache; `false` if the key is not in the cache.

### close

    public void close()

  Description copied from interface: `QueryCache`
  Close this cache, dropping all hard references and releasing any resources that this cache maintains.
  Specified by:
    `close` in interface `QueryCache`

### getExpirationListener

    public QueryKeyExpirationListener getExpirationListener()

  Description copied from interface: `QueryCache`
  Returns this query cache's expiration listener.
  Specified by:
    `getExpirationListener` in interface `QueryCache`

### setConfiguration

    public void setConfiguration(Configuration conf)

  Description copied from interface: `Configurable`
  Invoked prior to setting bean properties.
  Specified by:
    `setConfiguration` in interface `Configurable`

### startConfiguration

    public void startConfiguration()

  Description copied from interface: `Configurable`
  Invoked before bean property configuration is begun on this object.
  Specified by:
    `startConfiguration` in interface `Configurable`

### endConfiguration

    public void endConfiguration()

  Description copied from interface: `Configurable`
  Invoked upon completion of bean property configuration for this object.
  Specified by:
    `endConfiguration` in interface `Configurable`

Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.1.6 generated on August 25 2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.