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

## org.apache.cayenne.cache
Class NestedQueryCache

    java.lang.Object
      org.apache.cayenne.cache.NestedQueryCache

All Implemented Interfaces:
  QueryCache

    public class NestedQueryCache

extends java.lang.Object
implements QueryCache

A `QueryCache` wrapper that introduces a key namespace on top of a delegate shared cache. This way multiple cache users can share the same underlying cache without a possibility of key conflicts, yet refresh the cache groups in a coordinated fashion.

Since:
  3.0

Field Summary
`protected QueryCache` | `delegate`
`protected java.lang.String` | `namespace`

Constructor Summary
`NestedQueryCache(QueryCache delegate)`

Method Summary
`void` | `clear()` Clears the underlying shared cache.
`java.util.List` | `get(QueryMetadata metadata)` Returns a cached query result for the given QueryMetadata or null if the result is not cached or is expired.
`java.util.List` | `get(QueryMetadata metadata, QueryCacheEntryFactory factory)` Returns a cached query result for the given QueryMetadata.
`QueryCache` | `getDelegate()` Returns the actual implementation of the query cache that is wrapped by this NestedQueryCache.
`void` | `put(QueryMetadata metadata, java.util.List results)`
`void` | `remove(java.lang.String key)` Removes an entry for key in the current namespace.
`void` | `removeGroup(java.lang.String groupKey)` Invalidates a shared cache group.
`int` | `size()` Returns a shared cache size.

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

Field Detail

### delegate

    protected QueryCache delegate

### namespace

    protected java.lang.String namespace

Constructor Detail

### NestedQueryCache

    public NestedQueryCache(QueryCache delegate)

Method Detail

### getDelegate

    public QueryCache getDelegate()

  Returns the actual implementation of the query cache that is wrapped by this NestedQueryCache.

### clear

    public void clear()

  Clears the underlying shared cache.

  Specified by:
    `clear` in interface `QueryCache`

### get

    public java.util.List get(QueryMetadata metadata,
                              QueryCacheEntryFactory factory)

  Description copied from interface: `QueryCache`
  Returns a cached query result for the given QueryMetadata. If the result is not cached or is expired, cache will use provided factory to rebuild the value and store it in the cache. A corollary is that this method never returns null.

  Compared to `QueryCache.get(QueryMetadata)`, this method allows the cache to do appropriate synchronization when refreshing the entry, preventing multiple threads from running the same query when a missing entry is requested by multiple threads simultaneously.

  Specified by:
    `get` in interface `QueryCache`

### get

    public java.util.List get(QueryMetadata metadata)

  Description copied from interface: `QueryCache`
  Returns a cached query result for the given QueryMetadata or null if the result is not cached or is expired.

  Specified by:
    `get` in interface `QueryCache`

### put

    public void put(QueryMetadata metadata,
                    java.util.List results)

  Specified by:
    `put` in interface `QueryCache`

### remove

    public void remove(java.lang.String key)

  Removes an entry for key in the current namespace.

  Specified by:
    `remove` in interface `QueryCache`

### removeGroup

    public void removeGroup(java.lang.String groupKey)

  Invalidates a shared cache group.

  Specified by:
    `removeGroup` in interface `QueryCache`

### size

    public int size()

  Returns a shared cache size.

  Specified by:
    `size` in interface `QueryCache`

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

Copyright © 2001-2012 Apache Cayenne. All Rights Reserved.