com.caucho.server.distcache
Class CacheConfig

java.lang.Object
  extended by com.caucho.server.distcache.CacheConfig
All Implemented Interfaces:
CacheConfiguration

public class CacheConfig
extends java.lang.Object
implements CacheConfiguration

Manages the distributed cache


Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.cache.CacheConfiguration
CacheConfiguration.Duration, CacheConfiguration.ExpiryType
 
Field Summary
static int FLAG_BACKUP
           
static int FLAG_CLUSTER
           
static int FLAG_GLOBAL
           
static int FLAG_TRANSIENT
           
static int FLAG_TRIPLICATE
           
static long TIME_HOUR
           
static long TIME_INFINITY
           
 
Constructor Summary
CacheConfig()
           
 
Method Summary
 long getAccessedExpireTimeout()
          The maximum time that an item can remain in cache without being referenced.
 long getAccessedExpireTimeoutWindow()
          Returns the idle check window, i.e.
 HashKey getCacheKey()
          Returns the globally-unique id for the cache.
 CacheLoader getCacheLoader()
          The Cache will use a CacheLoader to populate cache misses.
 CacheWriter getCacheWriter()
           
 CacheEngine getEngine()
           
 CacheConfiguration.Duration getExpiry(CacheConfiguration.ExpiryType type)
           
 int getFlags()
          Returns internal flags
 java.lang.String getGuid()
          Returns the globally-unique id for the cache.
 CacheSerializer getKeySerializer()
          Returns the key serializer
 long getLeaseExpireTimeout()
          Returns the lease timeout, which is the time a server can use the local version if it owns it, before a timeout.
 long getLocalExpireTimeout()
          The local read timeout is the time a local copy of the cache is considered valid without checking the backing store.
 long getModifiedExpireTimeout()
          The maximum valid time for an item after a modification.
 long getModifiedExpireTimeoutWindow()
          Returns the expire check window, i.e.
 ResinCacheBuilder.Scope getScopeMode()
          Returns the AbstractCache.Scope defined for this cache.
 IsolationLevel getTransactionIsolationLevel()
           
 Mode getTransactionMode()
           
 CacheSerializer getValueSerializer()
          Returns the value serializer
 void init()
          Initializes the CacheConfig.
 boolean isBackup()
           
static boolean isBackup(int flags)
           
 boolean isGlobal()
          Sets the global mode.
static boolean isGlobal(int flags)
           
 boolean isReadThrough()
           
 boolean isStatisticsEnabled()
           
 boolean isStoreByValue()
           
 boolean isSynchronousGet()
          Returns true if all gets are synchronous, i.e.
 boolean isTransactionEnabled()
           
 boolean isTriplicate()
          Returns true is the triplicate backup mode enabled so that all triad servers have a copy of the cache item.
static boolean isTriplicate(int flags)
           
 boolean isWriteThrough()
           
 void setAccessedExpireTimeout(long timeout)
          The maximum time that an item can remain in cache without being referenced.
 void setAccessedExpireTimeoutWindow(long idleTimeoutWindow)
          Provides the option to set the idle check window, the amount of time in which the idle time limit can be spread out to smooth performance.
 void setCacheKey(HashKey cacheKey)
          Sets the globally-unique id for the cache
 void setCacheLoader(CacheLoader cacheLoader)
          Sets the CacheLoader that the Cache can then use to populate cache misses for a reference store (database)
 void setCacheWriter(CacheWriter cacheWriter)
           
 void setEngine(CacheEngine engine)
           
 void setExpiry(CacheConfiguration.ExpiryType type, CacheConfiguration.Duration duration)
           
 void setFlags(int flags)
          Sets internal flags
 void setGlobal(boolean isGlobal)
          Sets the global mode.
 void setGuid(java.lang.String guid)
          Sets the globally-unique id for the cache
 void setLeaseExpireTimeout(long timeout)
          The lease timeout is the time a server can use the local version if it owns it, before a timeout.
 void setLocalExpireTimeout(long timeout)
          The local expire time is the time a local copy of the cache is considered valid.
 void setModifiedExpireTimeout(long expireTimeout)
          The maximum valid time for an item.
 void setModifiedExpireTimeoutWindow(long expireTimeoutWindow)
          Provides the opportunity to control the expire check window, i.e.
 void setReadThrough(boolean isReadThrough)
           
 void setScopeMode(ResinCacheBuilder.Scope scope)
          Sets the AbstractCache.Scope of this cache.
 void setStatisticsEnabled(boolean isEnabled)
           
 void setStoreByValue(boolean isStoreByValue)
           
 void setValueSerializer(CacheSerializer serializer)
          Sets the value serializer
 void setWriteThrough(boolean isWriteThrough)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TIME_INFINITY

public static final long TIME_INFINITY
See Also:
Constant Field Values

TIME_HOUR

public static final long TIME_HOUR
See Also:
Constant Field Values

FLAG_TRANSIENT

public static final int FLAG_TRANSIENT
See Also:
Constant Field Values

FLAG_BACKUP

public static final int FLAG_BACKUP
See Also:
Constant Field Values

FLAG_TRIPLICATE

public static final int FLAG_TRIPLICATE
See Also:
Constant Field Values

FLAG_CLUSTER

public static final int FLAG_CLUSTER
See Also:
Constant Field Values

FLAG_GLOBAL

public static final int FLAG_GLOBAL
See Also:
Constant Field Values
Constructor Detail

CacheConfig

public CacheConfig()
Method Detail

getCacheLoader

public CacheLoader getCacheLoader()
The Cache will use a CacheLoader to populate cache misses.

Specified by:
getCacheLoader in interface CacheConfiguration

setCacheLoader

public void setCacheLoader(CacheLoader cacheLoader)
Sets the CacheLoader that the Cache can then use to populate cache misses for a reference store (database)


isReadThrough

public boolean isReadThrough()
Specified by:
isReadThrough in interface CacheConfiguration

setReadThrough

public void setReadThrough(boolean isReadThrough)

getCacheWriter

public CacheWriter getCacheWriter()
Specified by:
getCacheWriter in interface CacheConfiguration

setCacheWriter

public void setCacheWriter(CacheWriter cacheWriter)

isWriteThrough

public boolean isWriteThrough()
Specified by:
isWriteThrough in interface CacheConfiguration

setWriteThrough

public void setWriteThrough(boolean isWriteThrough)

getGuid

public java.lang.String getGuid()
Returns the globally-unique id for the cache.


setGuid

public void setGuid(java.lang.String guid)
Sets the globally-unique id for the cache


getCacheKey

public HashKey getCacheKey()
Returns the globally-unique id for the cache.


setCacheKey

public void setCacheKey(HashKey cacheKey)
Sets the globally-unique id for the cache


getFlags

public int getFlags()
Returns internal flags


setFlags

public void setFlags(int flags)
Sets internal flags


getModifiedExpireTimeout

public long getModifiedExpireTimeout()
The maximum valid time for an item after a modification. Items stored in the cache for longer than the expire time are no longer valid and will return null from a get. Default is infinite.


setModifiedExpireTimeout

@Configurable
public void setModifiedExpireTimeout(long expireTimeout)
The maximum valid time for an item. Items stored in the cache for longer than the expire time are no longer valid and will return null from a get. Default is infinite.


getModifiedExpireTimeoutWindow

public long getModifiedExpireTimeoutWindow()
Returns the expire check window, i.e. the precision of the expire check. Since an expired item can cause a massive cascade of attempted loads from the backup, the actual expiration is randomized.


setModifiedExpireTimeoutWindow

@Configurable
public void setModifiedExpireTimeoutWindow(long expireTimeoutWindow)
Provides the opportunity to control the expire check window, i.e. the precision of the expirecheck.

Since an expired item can cause a massive cascade of attempted loads from the backup, the actual expiration is randomized.


getAccessedExpireTimeout

public long getAccessedExpireTimeout()
The maximum time that an item can remain in cache without being referenced. For example, session data could be configured to be removed if idle for more than 30 minutes.

Cached data would typically have infinite idle time because it doesn't depend on how often it's accessed. Default is infinite.


setAccessedExpireTimeout

public void setAccessedExpireTimeout(long timeout)
The maximum time that an item can remain in cache without being referenced. For example, session data could be configured to be removed if idle for more than 30 minutes. Cached data would typically use an infinite idle time because it doesn't depend on how often it's accessed.


getAccessedExpireTimeoutWindow

public long getAccessedExpireTimeoutWindow()
Returns the idle check window, i.e. the precision of the idle check.


setAccessedExpireTimeoutWindow

public void setAccessedExpireTimeoutWindow(long idleTimeoutWindow)
Provides the option to set the idle check window, the amount of time in which the idle time limit can be spread out to smooth performance.

If this optional value is not set, the system uses a fraction of the idle time.


getLeaseExpireTimeout

public long getLeaseExpireTimeout()
Returns the lease timeout, which is the time a server can use the local version if it owns it, before a timeout.


setLeaseExpireTimeout

public void setLeaseExpireTimeout(long timeout)
The lease timeout is the time a server can use the local version if it owns it, before a timeout.


getLocalExpireTimeout

public long getLocalExpireTimeout()
The local read timeout is the time a local copy of the cache is considered valid without checking the backing store.


setLocalExpireTimeout

public void setLocalExpireTimeout(long timeout)
The local expire time is the time a local copy of the cache is considered valid.


isSynchronousGet

public boolean isSynchronousGet()
Returns true if all gets are synchronous, i.e. must be checked with the owning server on each request.


getKeySerializer

public CacheSerializer getKeySerializer()
Returns the key serializer


getValueSerializer

public CacheSerializer getValueSerializer()
Returns the value serializer


setValueSerializer

public void setValueSerializer(CacheSerializer serializer)
Sets the value serializer


isBackup

public boolean isBackup()

isBackup

public static boolean isBackup(int flags)

isGlobal

public boolean isGlobal()
Sets the global mode. If global is enabled, copies of the cache item will be sent to all clusters.

Defaults to false.


isGlobal

public static boolean isGlobal(int flags)

setGlobal

public void setGlobal(boolean isGlobal)
Sets the global mode. If global is enabled, copies of the cache item will be sent to all clusters.

Defaults to false.


isTriplicate

public boolean isTriplicate()
Returns true is the triplicate backup mode enabled so that all triad servers have a copy of the cache item.

Defaults is true.


isTriplicate

public static boolean isTriplicate(int flags)

setScopeMode

public void setScopeMode(ResinCacheBuilder.Scope scope)
Sets the AbstractCache.Scope of this cache.


getScopeMode

public ResinCacheBuilder.Scope getScopeMode()
Returns the AbstractCache.Scope defined for this cache.

Returns:

setEngine

public void setEngine(CacheEngine engine)

getEngine

public CacheEngine getEngine()

init

public void init()
Initializes the CacheConfig.


setExpiry

public void setExpiry(CacheConfiguration.ExpiryType type,
                      CacheConfiguration.Duration duration)

getExpiry

public CacheConfiguration.Duration getExpiry(CacheConfiguration.ExpiryType type)
Specified by:
getExpiry in interface CacheConfiguration

isStatisticsEnabled

public boolean isStatisticsEnabled()
Specified by:
isStatisticsEnabled in interface CacheConfiguration

setStatisticsEnabled

public void setStatisticsEnabled(boolean isEnabled)

isStoreByValue

public boolean isStoreByValue()
Specified by:
isStoreByValue in interface CacheConfiguration

setStoreByValue

public void setStoreByValue(boolean isStoreByValue)

isTransactionEnabled

public boolean isTransactionEnabled()
Specified by:
isTransactionEnabled in interface CacheConfiguration

getTransactionIsolationLevel

public IsolationLevel getTransactionIsolationLevel()
Specified by:
getTransactionIsolationLevel in interface CacheConfiguration

getTransactionMode

public Mode getTransactionMode()
Specified by:
getTransactionMode in interface CacheConfiguration

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object