Class QueryResultsCachePolicy

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class QueryResultsCachePolicy
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Cloneable
    PUBLIC: A QueryResultsCache policy dictates how a query's results will be cached. It allows an invalidation policy and a maximum number of results to be set. Query results are cached based on the parameter values of a query, and the maximum number of results refers to the maximum number of parameter sets results will be cached for.\ By default query result caching is not used.
    See Also:
    ReadQuery.setQueryResultsCachePolicy(QueryResultsCachePolicy), Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Class cacheType
      Allows the identity map class type to be set.
      protected boolean invalidateOnChange
      Allows the query cache to be invalidated when any object of any of the query classes is modified.
      protected java.util.Set<java.lang.Class> invalidationClasses
      Stores the set of classes that should trigger the query cached results to be invalidated.
      protected CacheInvalidationPolicy invalidationPolicy
      Allows invalidation to be specified.
      protected boolean isNullIgnored
      Allows the caching of null to be configured.
      protected int maximumResultSets
      Specifies the cache size.
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryResultsCachePolicy()
      PUBLIC: Build a QueryResultsCachePolicy with the default settings By default there is no invalidation of query results and the maximum number of results sets is 100.
      QueryResultsCachePolicy​(int maximumResultSets)
      PUBLIC: Build a QueryResultsCachePolicy and supply a maximum for the number of results sets.
      QueryResultsCachePolicy​(CacheInvalidationPolicy policy)
      PUBLIC: Build a QueryResultsCachePolicy and supply a CacheInvalidationPolicy.
      QueryResultsCachePolicy​(CacheInvalidationPolicy policy, int maximumResultSets)
      PUBLIC: Build a QueryResultsCachePolicy and supply a CacheInvalidationPolicy and a maximum number of results sets.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      QueryResultsCachePolicy clone()  
      CacheInvalidationPolicy getCacheInvalidationPolicy()
      PUBLIC: Return the query cache invalidation policy.
      java.lang.Class getCacheType()
      PUBLIC: Return the type of the cache used for the query results.
      boolean getInvalidateOnChange()
      PUBLIC: Return if any change to any object of the query class should cause the query results to be invalidated.
      java.util.Set<java.lang.Class> getInvalidationClasses()
      ADVANCED: Return the set of classes that should trigger the query cached results to be invalidated.
      int getMaximumCachedResults()
      PUBLIC: Return the maximum cached results.
      boolean isNullIgnored()
      PUBLIC: Return if null results should be cached or ignored.
      void setCacheInvalidationPolicy​(CacheInvalidationPolicy invalidationPolicy)
      PUBLIC: Set the query cache invalidation policy.
      void setCacheType​(java.lang.Class cacheType)
      PUBLIC: Set the type of the cache used for the query results.
      void setInvalidateOnChange​(boolean invalidateOnChange)
      PUBLIC: Configure if any change to any object of the query class should cause the query results to be invalidated.
      void setInvalidationClasses​(java.util.Set<java.lang.Class> invalidationClasses)
      ADVANCED: Set the set of classes that should trigger the query cached results to be invalidated.
      void setIsNullIgnored​(boolean isNullIgnored)
      PUBLIC: Set if null results should be cached or ignored.
      void setMaximumCachedResults​(int maximumResultSets)
      PUBLIC: Set the maximum cached results.
      void useFullCache()
      PUBLIC: Set the type of the cache used for the query results to a FullIdentityMap.
      void useLRUCache()
      PUBLIC: Set the type of the cache used for the query results to a CacheIdentityMap.
      void useSoftCache()
      PUBLIC: Set the type of the cache used for the query results to a SoftIdentityMap.
      void useSoftLRUCache()
      PUBLIC: Set the type of the cache used for the query results to a SoftCacheWeakIdentityMap.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • maximumResultSets

        protected int maximumResultSets
        Specifies the cache size.
      • cacheType

        protected java.lang.Class cacheType
        Allows the identity map class type to be set.
      • isNullIgnored

        protected boolean isNullIgnored
        Allows the caching of null to be configured.
      • invalidateOnChange

        protected boolean invalidateOnChange
        Allows the query cache to be invalidated when any object of any of the query classes is modified.
      • invalidationClasses

        protected java.util.Set<java.lang.Class> invalidationClasses
        Stores the set of classes that should trigger the query cached results to be invalidated.
    • Constructor Detail

      • QueryResultsCachePolicy

        public QueryResultsCachePolicy()
        PUBLIC: Build a QueryResultsCachePolicy with the default settings By default there is no invalidation of query results and the maximum number of results sets is 100.
      • QueryResultsCachePolicy

        public QueryResultsCachePolicy​(CacheInvalidationPolicy policy,
                                       int maximumResultSets)
        PUBLIC: Build a QueryResultsCachePolicy and supply a CacheInvalidationPolicy and a maximum number of results sets.
        See Also:
        CacheInvalidationPolicy
      • QueryResultsCachePolicy

        public QueryResultsCachePolicy​(CacheInvalidationPolicy policy)
        PUBLIC: Build a QueryResultsCachePolicy and supply a CacheInvalidationPolicy. The default value of 100 will be used for the maximum number of result sets
        See Also:
        CacheInvalidationPolicy
      • QueryResultsCachePolicy

        public QueryResultsCachePolicy​(int maximumResultSets)
        PUBLIC: Build a QueryResultsCachePolicy and supply a maximum for the number of results sets. Results will be set not to expire in the cache.
    • Method Detail

      • getInvalidationClasses

        public java.util.Set<java.lang.Class> getInvalidationClasses()
        ADVANCED: Return the set of classes that should trigger the query cached results to be invalidated.
      • setInvalidationClasses

        public void setInvalidationClasses​(java.util.Set<java.lang.Class> invalidationClasses)
        ADVANCED: Set the set of classes that should trigger the query cached results to be invalidated. This is normally computed by the query, but can be set in the case of native queries.
      • isNullIgnored

        public boolean isNullIgnored()
        PUBLIC: Return if null results should be cached or ignored. By default they are cached. They can be ignored to allow a query cache to be used as a secondary cache index, and allow new objects to be insert, and still found.
      • setIsNullIgnored

        public void setIsNullIgnored​(boolean isNullIgnored)
        PUBLIC: Set if null results should be cached or ignored. By default they are cached. They can be ignored to allow a query cache to be used as a secondary cache index, and allow new objects to be insert, and still found.
      • getInvalidateOnChange

        public boolean getInvalidateOnChange()
        PUBLIC: Return if any change to any object of the query class should cause the query results to be invalidated.
      • setInvalidateOnChange

        public void setInvalidateOnChange​(boolean invalidateOnChange)
        PUBLIC: Configure if any change to any object of the query class should cause the query results to be invalidated.
      • getCacheType

        public java.lang.Class getCacheType()
        PUBLIC: Return the type of the cache used for the query results. This defaults to a LRU cache (CacheIdentityMap), but can be set to any IdentityMap class, such as Full or Soft.
      • setCacheType

        public void setCacheType​(java.lang.Class cacheType)
        PUBLIC: Set the type of the cache used for the query results. This defaults to a LRU cache (CacheIdentityMap), but can be set to any IdentityMap class, such as Full or Soft.
      • useFullCache

        public void useFullCache()
        PUBLIC: Set the type of the cache used for the query results to a FullIdentityMap. This will cache all query results, so caution should be used to avoid running out of memory.
      • useSoftCache

        public void useSoftCache()
        PUBLIC: Set the type of the cache used for the query results to a SoftIdentityMap. This will cache all query results, unless the JVM believes memory is low.
      • useSoftLRUCache

        public void useSoftLRUCache()
        PUBLIC: Set the type of the cache used for the query results to a SoftCacheWeakIdentityMap. This will uses a fixed size LRU cache using Soft references, so will allow garbage collection when memory is low.
      • useLRUCache

        public void useLRUCache()
        PUBLIC: Set the type of the cache used for the query results to a CacheIdentityMap. This will uses a fixed size LRU cache. This is the default.
      • getCacheInvalidationPolicy

        public CacheInvalidationPolicy getCacheInvalidationPolicy()
        PUBLIC: Return the query cache invalidation policy. The cache invalidation policy defines how the query results are invalidated.
      • setCacheInvalidationPolicy

        public void setCacheInvalidationPolicy​(CacheInvalidationPolicy invalidationPolicy)
        PUBLIC: Set the query cache invalidation policy. The cache invalidation policy defines how the query results are invalidated.
      • getMaximumCachedResults

        public int getMaximumCachedResults()
        PUBLIC: Return the maximum cached results. This defines the number of query result sets that will be cached. The LRU query results will be discarded when the max size is reached.
      • setMaximumCachedResults

        public void setMaximumCachedResults​(int maximumResultSets)
        PUBLIC: Set the maximum cached results. This defines the number of query result sets that will be cached. The LRU query results will be discarded when the max size is reached.