org.qi4j.api.cache
Class CacheOptions

java.lang.Object
  extended by org.qi4j.api.cache.CacheOptions

public final class CacheOptions
extends Object

CacheOptions is a metaInfo class for the Cache system for Entity persistence. CacheOptions should be assigned to the Usecase of the UnitOfWork, to give hint on caching to entity stores. See UsecaseBuilder on how to set the metaInfo on Usecases.


Field Summary
static CacheOptions ALWAYS
           
static CacheOptions NEVER
           
 
Constructor Summary
CacheOptions(boolean cacheOnRead, boolean cacheOnWrite, boolean cacheOnNew)
          Constructor for CacheOptions.
 
Method Summary
 boolean cacheOnNew()
           
 boolean cacheOnRead()
           
 boolean cacheOnWrite()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALWAYS

public static final CacheOptions ALWAYS

NEVER

public static final CacheOptions NEVER
Constructor Detail

CacheOptions

public CacheOptions(boolean cacheOnRead,
                    boolean cacheOnWrite,
                    boolean cacheOnNew)
Constructor for CacheOptions.

Parameters:
cacheOnRead - if true, give the hint to the Cache system that it may not be a good idea to cache the read values. This is useful when it is known that the read will be over a large set and shouldn't affect the existing cached entities. For instance, when traversing the EntityStore this option is set to false.
cacheOnWrite - if true, give the hint to the Cache system that it may not be a good idea to cache the entity when the value is updated. If this is false, the cache should be emptied from any cached entity instead of updated. There are few cases when this is useful, and if this is false, it makes sense that the cacheOnRead is also false.
cacheOnNew - if true, give the hint to the Cache system that it may not be a good idea to cache a newly created Entity, as it is not likely to be read in the near future. This is useful when batch inserts are being made.
Method Detail

cacheOnRead

public boolean cacheOnRead()
Returns:
if true, give the hint to the Cache system that it may not be a good idea to cache the read values. This is useful when it is known that the read will be over a large set and shouldn't affect the existing cached entities. For instance, when traversing the EntityStore

cacheOnWrite

public boolean cacheOnWrite()
Returns:
if true, give the hint to the Cache system that it may not be a good idea to cache the entity when the value is updated. If this is false, the cache should be emptied from any cached entity instead of updated. There are few cases when this is useful, and if this is false, it makes sense that the cacheOnRead is also false.

cacheOnNew

public boolean cacheOnNew()
Returns:
if true, give the hint to the Cache system that it may not be a good idea to cache a newly created Entity, as it is not likely to be read in the near future. This is useful when batch inserts are being made.