Package org.javalite.activejdbc.cache
Enum QueryCache
- java.lang.Object
-
- java.lang.Enum<QueryCache>
-
- org.javalite.activejdbc.cache.QueryCache
-
- All Implemented Interfaces:
Serializable,Comparable<QueryCache>
public enum QueryCache extends Enum<QueryCache>
This is a main cache facade.- Author:
- Igor Polevoy
-
-
Enum Constant Summary
Enum Constants Enum Constant Description INSTANCE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddItem(String tableName, String query, Object[] params, Object cache)Adds an item to cache.CacheManagergetCacheManager()ObjectgetItem(String tableName, String query, Object[] params)Returns an item from cache, or null if nothing found.static QueryCacheinstance()This class is a singleton, get an instance with this method.booleanisEnabled()voidpurgeTableCache(String tableName)UsepurgeTableCache(MetaModel)whenever you can.voidpurgeTableCache(MetaModel metaModel)This method purges (removes) all caches associated with a table, if caching is enabled and a corresponding model is marked cached.static QueryCachevalueOf(String name)Returns the enum constant of this type with the specified name.static QueryCache[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
INSTANCE
public static final QueryCache INSTANCE
-
-
Method Detail
-
values
public static QueryCache[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (QueryCache c : QueryCache.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static QueryCache valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
isEnabled
public boolean isEnabled()
-
instance
public static QueryCache instance()
This class is a singleton, get an instance with this method.- Returns:
- one and only one instance of this class.
-
addItem
public void addItem(String tableName, String query, Object[] params, Object cache)
Adds an item to cache. Expected some lists of objects returned from "select" queries.- Parameters:
tableName- - name of table.query- query textparams- - list of parameters for a query.cache- object to cache.
-
getItem
public Object getItem(String tableName, String query, Object[] params)
Returns an item from cache, or null if nothing found.- Parameters:
tableName- name of table.query- query text.params- list of query parameters, can be null if no parameters are provided.- Returns:
- cache object or null if nothing found.
-
purgeTableCache
public void purgeTableCache(MetaModel metaModel)
This method purges (removes) all caches associated with a table, if caching is enabled and a corresponding model is marked cached.- Parameters:
metaModel- meta-model whose caches are to purge.
-
purgeTableCache
public void purgeTableCache(String tableName)
UsepurgeTableCache(MetaModel)whenever you can.- Parameters:
tableName- name of table whose caches to purge.
-
getCacheManager
public CacheManager getCacheManager()
-
-