org.datanucleus.store.query.cache
Class AbstractQueryResultsCache

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

public class AbstractQueryResultsCache
extends java.lang.Object
implements QueryResultsCache

Abstract representation of a query results cache for the query.


Constructor Summary
AbstractQueryResultsCache(OMFContext omfCtx)
           
 
Method Summary
 void close()
          Method to close the cache when no longer needed.
 boolean contains(java.lang.String queryKey)
          Accessor for whether the specified query is in the cache
 void evict(Query query)
          Evict the query from the results cache.
 void evict(Query query, java.util.Map params)
          Evict the query with the specified params from the results cache.
 void evictAll()
          Method to clear the cache.
 java.util.List<java.lang.Object> get(java.lang.String queryKey)
          Accessor for the results from the cache.
 boolean isEmpty()
          Accessor for whether the cache is empty.
 void pin(Query query)
          Method to pin the specified query in the cache, preventing garbage collection.
 void pin(Query query, java.util.Map params)
          Method to pin the specified query in the cache, preventing garbage collection.
 java.util.List<java.lang.Object> put(java.lang.String queryKey, java.util.List<java.lang.Object> results)
          Method to put an object in the cache.
 int size()
          Accessor for the total number of results in the query cache.
 void unpin(Query query)
          Method to unpin the specified query from the cache, allowing garbage collection.
 void unpin(Query query, java.util.Map params)
          Method to unpin the specified query from the cache, allowing garbage collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractQueryResultsCache

public AbstractQueryResultsCache(OMFContext omfCtx)
Method Detail

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(java.lang.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

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,
                  java.util.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,
                java.util.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,
                  java.util.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 java.util.List<java.lang.Object> get(java.lang.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 java.util.List<java.lang.Object> put(java.lang.String queryKey,
                                            java.util.List<java.lang.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


Copyright © 2011. All Rights Reserved.