春天redis增量

时间:2015-12-16 01:21:05

标签: spring redis

我想用memcached替换spring-redis。

memcached有功能

         *  @param key         key
         * @param delta
         *            increment delta
         * @param initValue
         *            the initial value to be added when value is not found
         * @param timeout
         *            operation timeout
         * @param exp
         *            the initial vlaue expire time, in seconds. Can be up to 30
         *            days. After 30 days, is treated as a unix timestamp of an
         *            exact date.
         * @return
         * @throws TimeoutException
         * @throws InterruptedException
         * @throws MemcachedException
         */
        long incr(String key, long delta, long initValue, long timeout, int exp)
                throws TimeoutException, InterruptedException, MemcachedException;

spring-redis有功能

Long increment(K key, long delta);

如何在spring-redis中设置操作超时(不过期)?

1 个答案:

答案 0 :(得分:1)

spring-redis不允许您为每个请求配置超时(如在memcached实现中)。您可以使用application.properties中的配置设置配置每个连接的超时:

  

spring.redis.timeout = 5000