List of usage examples for org.springframework.data.redis.core RedisCallback RedisCallback
RedisCallback
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Mark the start of a transaction block. <br> * Commands will be queued and can then be executed by calling {@link #exec()} or rolled back using {@link #discard()} * <p>//from w w w . j a va2s . c o m * See http://redis.io/commands/multi */ public static void multi() { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.multi(); return null; } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Mark the start of a transaction block. <br> * Commands will be queued and can then be executed by calling {@link #exec()} or rolled back using {@link #discard()} * <p>//from w w w. j av a 2 s . com * See http://redis.io/commands/multi */ public void multi() { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.multi(); return null; } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Executes all queued commands in a transaction started with {@link #multi()}. <br> * If used along with {@link #watch(byte[])} the operation will fail if any of watched keys has been modified. * <p>// w w w . j a v a 2s.c o m * See http://redis.io/commands/exec * * @return List of replies for each executed command. */ public static List<Object> exec() { return redisTemplate.execute(new RedisCallback<List<Object>>() { @Override public List<Object> doInRedis(RedisConnection redis) throws DataAccessException { return redis.exec(); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Executes all queued commands in a transaction started with {@link #multi()}. <br> * If used along with {@link #watch(byte[])} the operation will fail if any of watched keys has been modified. * <p>//from w w w. j av a 2s . c om * See http://redis.io/commands/exec * * @return List of replies for each executed command. */ public List<Object> exec() { return redisTemplate.execute(new RedisCallback<List<Object>>() { @Override public List<Object> doInRedis(RedisConnection redis) throws DataAccessException { return redis.exec(); } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Discard all commands issued after {@link #multi()}. * <p>/*from ww w.ja va 2s . c o m*/ * See http://redis.io/commands/discard */ public static void discard() { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.discard(); return null; } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Discard all commands issued after {@link #multi()}. * <p>//w w w . ja v a 2 s . co m * See http://redis.io/commands/discard */ public void discard() { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.discard(); return null; } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Watch given {@code keys} for modifications during transaction started with {@link #multi()}. * <p>//from www . ja va 2 s .com * See http://redis.io/commands/watch * * @param keys keys */ public static void watch(byte[]... keys) { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.watch(keys); return null; } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Watch given {@code keys} for modifications during transaction started with {@link #multi()}. * <p>//from www . j a v a 2 s . c o m * See http://redis.io/commands/watch * * @param keys keys */ public void watch(byte[]... keys) { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.watch(keys); return null; } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Flushes all the previously {@link #watch(byte[])} keys. * <p>/*from w w w.j a v a 2 s . c o m*/ * See http://redis.io/commands/unwatch */ public static void unwatch() { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.unwatch(); return null; } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Flushes all the previously {@link #watch(byte[])} keys. * <p>/*from w w w. j ava 2 s. com*/ * See http://redis.io/commands/unwatch */ public void unwatch() { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.unwatch(); return null; } }); }