Class AbstractMapQueryResultsCache

java.lang.Object
org.datanucleus.store.query.cache.AbstractMapQueryResultsCache
All Implemented Interfaces:
Serializable, QueryResultsCache
Direct Known Subclasses:
SoftQueryResultsCache, StrongQueryResultsCache, WeakQueryResultsCache

public class AbstractMapQueryResultsCache extends Object implements QueryResultsCache
Abstract representation of a query results cache for the query based on a map.
See Also:
  • Field Details

  • Constructor Details

    • AbstractMapQueryResultsCache

      public AbstractMapQueryResultsCache(NucleusContext nucleusCtx)
  • Method Details

    • close

      public void close()
      Description copied from interface: QueryResultsCache
      Method to close the cache when no longer needed. Provides a hook to release resources etc.
      Specified by:
      close in interface QueryResultsCache
    • contains

      public boolean contains(String queryKey)
      Description copied from interface: QueryResultsCache
      Accessor for whether the specified query is in the cache
      Specified by:
      contains in interface QueryResultsCache
      Parameters:
      queryKey - The query key
      Returns:
      Whether it is in the cache
    • evict

      public void evict(Class candidate)
      Description copied from interface: QueryResultsCache
      Method to evict all queries that use the provided class as candidate. This is usually called when an instance of the candidate has been changed in the datastore.
      Specified by:
      evict in interface QueryResultsCache
      Parameters:
      candidate - The candidate
    • evictAll

      public void evictAll()
      Description copied from interface: QueryResultsCache
      Method to clear the cache.
      Specified by:
      evictAll in interface QueryResultsCache
    • evict

      public void evict(Query query)
      Description copied from interface: QueryResultsCache
      Evict the query from the results cache.
      Specified by:
      evict in interface QueryResultsCache
      Parameters:
      query - The query to evict (evicts all use of this query, with any params)
    • evict

      public void evict(Query query, Map params)
      Description copied from interface: QueryResultsCache
      Evict the query with the specified params from the results cache.
      Specified by:
      evict in interface QueryResultsCache
      Parameters:
      query - The query to evict
      params - The parameters
    • pin

      public void pin(Query query, Map params)
      Description copied from interface: QueryResultsCache
      Method to pin the specified query in the cache, preventing garbage collection.
      Specified by:
      pin in interface QueryResultsCache
      Parameters:
      query - The query
      params - Its params
    • pin

      public void pin(Query query)
      Description copied from interface: QueryResultsCache
      Method to pin the specified query in the cache, preventing garbage collection.
      Specified by:
      pin in interface QueryResultsCache
      Parameters:
      query - The query
    • unpin

      public void unpin(Query query, Map params)
      Description copied from interface: QueryResultsCache
      Method to unpin the specified query from the cache, allowing garbage collection.
      Specified by:
      unpin in interface QueryResultsCache
      Parameters:
      query - The query
      params - Its params
    • unpin

      public void unpin(Query query)
      Description copied from interface: QueryResultsCache
      Method to unpin the specified query from the cache, allowing garbage collection.
      Specified by:
      unpin in interface QueryResultsCache
      Parameters:
      query - The query
    • get

      public List<Object> get(String queryKey)
      Description copied from interface: QueryResultsCache
      Accessor for the results from the cache.
      Specified by:
      get in interface QueryResultsCache
      Parameters:
      queryKey - The query key
      Returns:
      The cached query result ids
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: QueryResultsCache
      Accessor for whether the cache is empty.
      Specified by:
      isEmpty in interface QueryResultsCache
      Returns:
      Whether it is empty.
    • put

      public List<Object> put(String queryKey, List<Object> results)
      Description copied from interface: QueryResultsCache
      Method to put an object in the cache.
      Specified by:
      put in interface QueryResultsCache
      Parameters:
      queryKey - The query key
      results - The results for this query
      Returns:
      The result ids previously associated with this query (if any)
    • size

      public int size()
      Description copied from interface: QueryResultsCache
      Accessor for the total number of results in the query cache.
      Specified by:
      size in interface QueryResultsCache
      Returns:
      Number of queries