org.apache.cayenne.cache

## Class OSQueryCache

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

- All Implemented Interfaces:
    QueryCache

  Deprecated.
  since 4.0 as OSCache project is abandoned

      @Deprecated
      public class OSQueryCache
      extends Object
      implements QueryCache

  A `QueryCache` implementation based on OpenSymphony OSCache. Query cache parameters are initialized from "/oscache.properties" file per OSCache documentation. In addition to the standard OSCache parameters, Cayenne provider allows to setup global cache expiration parameters, and parameters matching the main query cache group (i.e. the cache groups specified first). A sample oscache.properties may look like this:

       # OSCache configuration file

       # OSCache standard configuration per
       #     http://www.opensymphony.com/oscache/wiki/Configuration.html
       # ---------------------------------------------------------------

       #cache.memory=true
       #cache.blocking=false
       cache.capacity=5000
       cache.algorithm=com.opensymphony.oscache.base.algorithm.LRUCache

       # Cayenne specific properties
       # ---------------------------------------------------------------

       # Default refresh period in seconds:
       cayenne.default.refresh = 60

       # Default expiry specified as cron expressions per
       #    http://www.opensymphony.com/oscache/wiki/Cron%20Expressions.html
       # expire entries every hour on the 10's minute
       cayenne.default.cron = 10 * * * *

       # Same parameters can be overridden per query
       cayenne.group.xyz.refresh = 120
       cayenne.group.xyz.cron = 10 1 * * *

  Further extension of OSQueryCache is possible by using OSCache listener API.
  Since:
    3.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_REFRESH_PERIOD` Deprecated.
    `protected com.opensymphony.oscache.general.GeneralCacheAdministrator` | `osCache` Deprecated.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OSQueryCache()` Deprecated.
    `OSQueryCache(com.opensymphony.oscache.general.GeneralCacheAdministrator cache, Properties properties)` Deprecated.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `capacity()` Deprecated.
    `void` | `clear()` Deprecated. Clears all cache entries.
    `List` | `get(QueryMetadata metadata)` Deprecated. 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)` Deprecated. Returns a non-null cached value.
    `String` | `getCronExpression(String groupName)` Deprecated.
    `Collection` | `getGroupNames()` Deprecated. Returns a collection of group names that have been configured explicitly via properties.
    `com.opensymphony.oscache.general.GeneralCacheAdministrator` | `getOsCache()` Deprecated. Returns the underlying OSCache manager object.
    `Properties` | `getProperties()` Deprecated. Returns configuration properties.
    `int` | `getRrefreshPeriod(String groupName)` Deprecated.
    `protected void` | `initCronPolicy(String groupName, Object value)` Deprecated. Called internally for each group that is configured with cron policy in the properties.
    `protected void` | `initRefreshPolicy(String groupName, Object value)` Deprecated. Called internally for each group that is configured with refresh policy in the properties.
    `void` | `put(QueryMetadata metadata, List results)` Deprecated.
    `void` | `remove(String key)` Deprecated. Removes a single entry from cache.
    `void` | `removeGroup(String groupKey)` Deprecated. Removes a group of entries identified by group key.
    `void` | `removeGroup(String groupKey, Class<?> keyType, Class<?> valueType)` Deprecated. Removes a group of entries identified by group key.
    `void` | `shutdown()` Deprecated. Shuts down EhCache CacheManager
    `int` | `size()` Deprecated. 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

    - #### DEFAULT_REFRESH_PERIOD

          public static final int DEFAULT_REFRESH_PERIOD

      Deprecated.
      See Also:
        Constant Field Values

    - #### osCache

          protected com.opensymphony.oscache.general.GeneralCacheAdministrator osCache

      Deprecated.

  - ### Constructor Detail

    - #### OSQueryCache

          public OSQueryCache()

      Deprecated.

    - #### OSQueryCache

          public OSQueryCache(com.opensymphony.oscache.general.GeneralCacheAdministrator cache,
                              Properties properties)

      Deprecated.

  - ### Method Detail

    - #### getGroupNames

          public Collection getGroupNames()

      Deprecated.
      Returns a collection of group names that have been configured explicitly via properties.

    - #### getCronExpression

          public String getCronExpression(String groupName)

      Deprecated.

    - #### getRrefreshPeriod

          public int getRrefreshPeriod(String groupName)

      Deprecated.

    - #### getOsCache

          public com.opensymphony.oscache.general.GeneralCacheAdministrator getOsCache()

      Deprecated.
      Returns the underlying OSCache manager object.

    - #### getProperties

          public Properties getProperties()

      Deprecated.
      Returns configuration properties. Usually this is the contents of "oscache.properties" file.

    - #### initCronPolicy

          protected void initCronPolicy(String groupName,
                                        Object value)

      Deprecated.
      Called internally for each group that is configured with cron policy in the properties. Exposed mainly for the benefit of subclasses. When overriding, call 'super'.

    - #### initRefreshPolicy

          protected void initRefreshPolicy(String groupName,
                                           Object value)

      Deprecated.
      Called internally for each group that is configured with refresh policy in the properties. Exposed mainly for the benefit of subclasses. When overriding, call 'super'.

    - #### get

          public List get(QueryMetadata metadata)

      Deprecated.
      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)

      Deprecated.
      Returns a non-null cached value. If it is not present in the cache, it is obtained by calling `QueryCacheEntryFactory.createObject()`. Whether the cache provider will block on the entry update or not is controlled by "cache.blocking" configuration property and is "false" by default.
      Specified by:
        `get` in interface `QueryCache`

    - #### put

          public void put(QueryMetadata metadata,
                          List results)

      Deprecated.
      Specified by:
        `put` in interface `QueryCache`

    - #### remove

          public void remove(String key)

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

    - #### removeGroup

          public void removeGroup(String groupKey)

      Deprecated.
      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`

    - #### removeGroup

          public void removeGroup(String groupKey,
                                  Class<?> keyType,
                                  Class<?> valueType)

      Deprecated.
      Description copied from interface: `QueryCache`
      Removes a group of entries identified by group key. Can be used if cache provider supports strictly typed caches.
      Specified by:
        `removeGroup` in interface `QueryCache`
      See Also:
        `QueryCache.removeGroup(String)`

    - #### clear

          public void clear()

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

    - #### size

          public int size()

      Deprecated.
      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`

    - #### capacity

          public int capacity()

      Deprecated.

    - #### shutdown

          @BeforeScopeEnd
          public void shutdown()

      Deprecated.
      Shuts down EhCache CacheManager

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