com.ibatis.sqlmap.engine.cache
Class CacheModel

java.lang.Object
  extended by com.ibatis.sqlmap.engine.cache.CacheModel
所有已实现接口:
ExecuteListener

public class CacheModel
extends java.lang.Object
implements ExecuteListener

Wrapper for Caches.


字段摘要
static java.lang.Object NULL_OBJECT
          This is used to represent null objects that are returned from the cache so that they can be cached, too.
 
构造器摘要
CacheModel()
          Default constructor
 
方法摘要
 void addFlushTriggerStatement(java.lang.String statementName)
          Adds a flushTriggerStatment.
 void configure(java.util.Properties props)
          Configures the cache
 void flush()
          Clears the cache
 long getFlushInterval()
          Getter for flushInterval property
 long getFlushIntervalSeconds()
          Getter for flushInterval property
 java.util.Iterator getFlushTriggerStatementNames()
          Gets an Iterator containing all flushTriggerStatment objects for this cache.
 double getHitRatio()
          Returns statistical information about the cache.
 java.lang.String getId()
          Getter for the cache model's id
protected  int getMaxObjectLogSize()
          Get the maximum size of an object in the log output.
 java.lang.Object getObject(CacheKey key)
          Get an object out of the cache.
 java.lang.String getResource()
          Getter for resource property
 boolean isReadOnly()
          Getter for read-only property
 boolean isSerialize()
          Getter to tell if the cache serializes
protected  void log(java.lang.String action, boolean addValue, java.lang.Object cacheValue)
          Log a cache action.
 void onExecuteStatement(MappedStatement statement)
          ExecuteListener event.
 void putObject(CacheKey key, java.lang.Object value)
          Add an object to the cache
 void setCacheController(CacheController controller)
          Sets up the controller for the cache model
 void setControllerProperties(java.util.Properties cacheProps)
           
 void setFlushInterval(long flushInterval)
          Setter for flushInterval property
 void setId(java.lang.String id)
          Setter for the cache model's id
 void setReadOnly(boolean readOnly)
          Setter for read-only property
 void setResource(java.lang.String resource)
          Setter for resource property
 void setSerialize(boolean serialize)
          Setter to tell the cache to serialize objects
 
类方法继承: java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

NULL_OBJECT

public static final java.lang.Object NULL_OBJECT
This is used to represent null objects that are returned from the cache so that they can be cached, too.

构造器详细信息

CacheModel

public CacheModel()
Default constructor

方法详细信息

getId

public java.lang.String getId()
Getter for the cache model's id

返回:
the id

setId

public void setId(java.lang.String id)
Setter for the cache model's id

参数:
id - - the new id

isReadOnly

public boolean isReadOnly()
Getter for read-only property

返回:
true if a read-only model

setReadOnly

public void setReadOnly(boolean readOnly)
Setter for read-only property

参数:
readOnly - - the new setting

isSerialize

public boolean isSerialize()
Getter to tell if the cache serializes

返回:
true if the cache model serializes objects

setSerialize

public void setSerialize(boolean serialize)
Setter to tell the cache to serialize objects

参数:
serialize - - if the cache model is to serialize objects

getResource

public java.lang.String getResource()
Getter for resource property

返回:
the value of the resource property

setResource

public void setResource(java.lang.String resource)
Setter for resource property

参数:
resource - - the new value

setCacheController

public void setCacheController(CacheController controller)
                        throws java.lang.ClassNotFoundException,
                               java.lang.InstantiationException,
                               java.lang.IllegalAccessException
Sets up the controller for the cache model

抛出异常:
java.lang.ClassNotFoundException - - if the class cannot be found
java.lang.InstantiationException - - if the class cannot be instantiated
java.lang.IllegalAccessException - - if the classes constructor is not accessible

getFlushInterval

public long getFlushInterval()
Getter for flushInterval property

返回:
The flushInterval (in milliseconds)

getFlushIntervalSeconds

public long getFlushIntervalSeconds()
Getter for flushInterval property

返回:
The flushInterval (in milliseconds)

setFlushInterval

public void setFlushInterval(long flushInterval)
Setter for flushInterval property

参数:
flushInterval - The new flushInterval (in milliseconds)

addFlushTriggerStatement

public void addFlushTriggerStatement(java.lang.String statementName)
Adds a flushTriggerStatment. When a flushTriggerStatment is executed, the cache is flushed (cleared).

参数:
statementName - The statement to add.

getFlushTriggerStatementNames

public java.util.Iterator getFlushTriggerStatementNames()
Gets an Iterator containing all flushTriggerStatment objects for this cache.

返回:
The Iterator

onExecuteStatement

public void onExecuteStatement(MappedStatement statement)
ExecuteListener event. This will be called by a MappedStatement for which this cache is registered as a ExecuteListener. It will be called each time an executeXXXXXX method is called. In the case of the Cache class, it is registered in order to flush the cache whenever a certain statement is executed. (i.e. the flushOnExecute cache policy)

规范说明:
onExecuteStatement in interface ExecuteListener
参数:
statement - The statement to execute

getHitRatio

public double getHitRatio()
Returns statistical information about the cache.

返回:
the number of cache hits divided by the total requests

configure

public void configure(java.util.Properties props)
Configures the cache

参数:
props -

flush

public void flush()
Clears the cache


getObject

public java.lang.Object getObject(CacheKey key)
Get an object out of the cache. A side effect of this method is that is may clear the cache if it has not been cleared in the flushInterval.

参数:
key - The key of the object to be returned
返回:
The cached object (or null)

putObject

public void putObject(CacheKey key,
                      java.lang.Object value)
Add an object to the cache

参数:
key - The key of the object to be cached
value - The object to be cached

getMaxObjectLogSize

protected int getMaxObjectLogSize()
Get the maximum size of an object in the log output.

返回:
Maximum size of a logged object in the output

log

protected void log(java.lang.String action,
                   boolean addValue,
                   java.lang.Object cacheValue)
Log a cache action. Since this method is pretty heavy weight, it's best to enclose it with a log.isDebugEnabled() when called.

参数:
action - String to output
addValue - Add the value being cached to the log
cacheValue - The value being logged

setControllerProperties

public void setControllerProperties(java.util.Properties cacheProps)