Enum CacheMode
- java.lang.Object
-
- java.lang.Enum<CacheMode>
-
- io.ebean.CacheMode
-
- All Implemented Interfaces:
Serializable
,Comparable<CacheMode>
public enum CacheMode extends Enum<CacheMode>
Enum to control the different cache modes for queryCache and beanCache.Bean cache
The bean cache is automatically used by default on
@Cache
beans for the following queries:- findOne() by id
- findOne() by natural key(s)
- findList() by ids
Bean caching needs to be explicitly turned on for queries that are findList() by natural keys.
Query cache
For query cache use note that you must be careful, what you do with the returned collection. By default the returned collections are read only and you will get an exception if you try to change them. If you add ".setReadOnly(false)" to your query, you'll get a collection that is a clone from the one in the cache. That means, changing does not affect the cache.
- Author:
- Roland Praml, FOCONIS AG
-
-
Enum Constant Summary
Enum Constants Enum Constant Description AUTO
Only used for bean caching.GET
GET only from the cache.OFF
Do not use cache.ON
Use the cache and store a result when needed.PUT
Do not read from cache, but put beans into the cache and invalidate parts of the cache as necessary.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isGet()
Return true if value is read from cache.boolean
isPut()
Return true if a newly loaded value (from database) is put into the cache.static CacheMode
valueOf(String name)
Returns the enum constant of this type with the specified name.static CacheMode[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
AUTO
public static final CacheMode AUTO
Only used for bean caching.The bean cache is automatically used by default on
@Cache
beans for the following queries:- findOne() by id
- findOne() by natural key(s)
- findList() by ids
Bean caching needs to be explicitly turned on for queries that are findList() by natural keys.
-
PUT
public static final CacheMode PUT
Do not read from cache, but put beans into the cache and invalidate parts of the cache as necessary.Use this on a query if you want to get the fresh value from database and put it into the cache.
-
-
Method Detail
-
values
public static CacheMode[] 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 (CacheMode c : CacheMode.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static CacheMode 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
-
isGet
public boolean isGet()
Return true if value is read from cache.
-
isPut
public boolean isPut()
Return true if a newly loaded value (from database) is put into the cache.
-
-