simple-spring-memcached 简称:ssm
由于现在的项目spring 为2.5.6,所以使用SSM1.0. SSM2.0以及3.0都是针对spring3.x,SSM3.0做了大量改进.
public @interface UpdateSingleCache {
/**
* A namespace that is added to the key as it is stored in the distributed cache.
* This allows differing object that may have the same ID to coexist.
* This value must be assigned.
* @return the namespace for the objects cached in the given method.
*/
String namespace() default AnnotationConstants.DEFAULT_STRING;
/**
* Of the arguments passed into the cached method, this identifies which
* argument provides the id by which the object will be cached. This is a
* 0-based array index. This annotation also takes a special value of -1 to signify
* that the object being returned is the object responsible for providing the cache key.
* @return the index into the arguments array for the item that will provide the id
*/
int keyIndex() default Integer.MIN_VALUE;
/**
* Since keys and the actual data to be cached may be different, we also need to know which
* parameter (or output) holds the data that we should update the cache with. This is a
* 0-based array index. This annotation also takes a special value of -1 to signify
* that the object being returned is the data that should be cached.
* @return the index into the argument array that holds the actual data to be cached
*/
int dataIndex() default Integer.MIN_VALUE;
/**
* The exp value is passed along to memcached exactly as given, and will be
* processed per the memcached protocol specification:
*
* The actual value sent may either be Unix time (number of seconds since January 1, 1970,
* as a 32-bit value), or a number of seconds starting from current time. In the latter case,
* this number of seconds may not exceed 60*60*24*30 (number of seconds in 30 days); if the
* number sent by a client is larger than that, the server will consider it to be real Unix
* time value rather than an offset from current time.
*
* (Also note: a value of 0 means the given value should never expire. The value is still
* susceptible to purging by memcached for space and LRU (least recently used) considerations.)
*
* @return
*/
int expiration() default 0;
}
keyIndex: 方法参数提供缓存key的下标值,下标从0开始. 当keyIndex=-1 缓存key值从返回值中提供.
如果参数为对象,则调用对象@CacheKeyMethod方法计算key值,如果没有@CacheKeyMethod注解则调用对象toString方法.
dataIndex: 参数作为缓存内容的下标值. 当dataIndex=-1,则从将返回值做为缓存内容
expiration: 过期时间 秒为单位 (60*60*24*30 (代表 30 天));