SSM1.0中UpdateSingleCache 参数keyIndex,dataIndex解释

9 篇文章 0 订阅

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 天));

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值