org.apache.cayenne.cache

## Class EhCacheQueryCache

- java.lang.Object
- - org.apache.cayenne.cache.EhCacheQueryCache

- All Implemented Interfaces:
    QueryCache

      public class EhCacheQueryCache
      extends Object
      implements QueryCache

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CacheManager` | `cacheManager`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EhCacheQueryCache()`
    `EhCacheQueryCache(CacheManager cacheManager)`
    `EhCacheQueryCache(String configFile)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clears all cache entries.
    `List` | `get(QueryMetadata metadata)` Returns a cached query result for the given QueryMetadata or null if the result is not cached or is expired.
    `List` | `get(QueryMetadata metadata, QueryCacheEntryFactory factory)` Returns a cached query result for the given QueryMetadata.
    `Ehcache` | `getDefaultCache()` Returns default cache group.
    `void` | `put(QueryMetadata metadata, List results)`
    `void` | `remove(String key)` Removes a single entry from cache.
    `void` | `removeGroup(String groupKey)` Removes a group of entries identified by group key.
    `void` | `shutdown()` Shuts down EhCache CacheManager
    `int` | `size()` Returns the number of entries currently in the cache, including expired but not removed entries.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### cacheManager

          protected CacheManager cacheManager

  - ### Constructor Detail

    - #### EhCacheQueryCache

          public EhCacheQueryCache()

    - #### EhCacheQueryCache

          public EhCacheQueryCache(String configFile)

    - #### EhCacheQueryCache

          public EhCacheQueryCache(CacheManager cacheManager)

  - ### Method Detail

    - #### get

          public 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`

    - #### get

          public 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`

    - #### put

          public void put(QueryMetadata metadata,
                          List results)

      Specified by:
        `put` in interface `QueryCache`

    - #### remove

          public void remove(String key)

      Description copied from interface: `QueryCache`
      Removes a single entry from cache.
      Specified by:
        `remove` in interface `QueryCache`

    - #### removeGroup

          public void removeGroup(String groupKey)

      Description copied from interface: `QueryCache`
      Removes a group of entries identified by group key. Note that depending on implementation this method may either actively remove the entries belonging to the group or just mark them as expired, so that they are refreshed on the next access. In the former case the cache size would shrink, but in the later the cache size will not change after calling this method.
      Specified by:
        `removeGroup` in interface `QueryCache`

    - #### clear

          public void clear()

      Description copied from interface: `QueryCache`
      Clears all cache entries.
      Specified by:
        `clear` in interface `QueryCache`

    - #### size

          public int size()

      Description copied from interface: `QueryCache`
      Returns the number of entries currently in the cache, including expired but not removed entries.
      Specified by:
        `size` in interface `QueryCache`

    - #### getDefaultCache

          public Ehcache getDefaultCache()

      Returns default cache group.

    - #### shutdown

          @BeforeScopeEnd
          public void shutdown()

      Shuts down EhCache CacheManager

Copyright © 2001–2018 Apache Cayenne. All rights reserved.