List of usage examples for org.springframework.data.redis.core RedisCallback RedisCallback
RedisCallback
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Use a {@link Cursor} to iterate over keys. * <p>/*from w ww. j a v a2s . c om*/ * See http://redis.io/commands/scan * * @param options options * @return Cursor<byte[]> * @since 1.4 */ public Cursor<byte[]> scan(ScanOptions options) { return redisTemplate.execute(new RedisCallback<Cursor<byte[]>>() { @Override public Cursor<byte[]> doInRedis(RedisConnection redis) throws DataAccessException { return redis.scan(options); } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Rename key {@code oleName} to {@code newName}. * <p>//from w w w .ja v a 2 s . c o m * See http://redis.io/commands/rename * * @param oldName oldName * @param newName newName */ public static void rename(byte[] oldName, byte[] newName) { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.rename(oldName, newName); return null; } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Return a random key from the keyspace. * <p>// w ww . j a v a2 s.c o m * See http://redis.io/commands/randomkey * * @return byte[] */ public byte[] randomKey() { return redisTemplate.execute(new RedisCallback<byte[]>() { @Override public byte[] doInRedis(RedisConnection redis) throws DataAccessException { return redis.randomKey(); } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Rename key {@code oleName} to {@code newName} only if {@code newName} does not exist. * <p>/*from w ww. j a v a 2 s. c om*/ * See http://redis.io/commands/renamenx * * @param oldName oldName * @param newName newName * @return Boolean */ public static Boolean renameNX(byte[] oldName, byte[] newName) { return redisTemplate.execute(new RedisCallback<Boolean>() { @Override public Boolean doInRedis(RedisConnection redis) throws DataAccessException { return redis.renameNX(oldName, newName); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Rename key {@code oleName} to {@code newName}. * <p>//from w w w. j a v a2s .c om * See http://redis.io/commands/rename * * @param oldName oldName * @param newName newName */ public void rename(byte[] oldName, byte[] newName) { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.rename(oldName, newName); return null; } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Set time to live for given {@code key} in seconds. * <p>/* w ww . j a v a 2s . co m*/ * See http://redis.io/commands/expire * * @param key key * @param seconds seconds * @return Boolean */ public static Boolean expire(byte[] key, long seconds) { return redisTemplate.execute(new RedisCallback<Boolean>() { @Override public Boolean doInRedis(RedisConnection redis) throws DataAccessException { return redis.expire(key, seconds); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Rename key {@code oleName} to {@code newName} only if {@code newName} does not exist. * <p>/*from ww w . ja va 2s . co m*/ * See http://redis.io/commands/renamenx * * @param oldName oldName * @param newName newName * @return Boolean */ public Boolean renameNX(byte[] oldName, byte[] newName) { return redisTemplate.execute(new RedisCallback<Boolean>() { @Override public Boolean doInRedis(RedisConnection redis) throws DataAccessException { return redis.renameNX(oldName, newName); } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Set time to live for given {@code key} in milliseconds. * <p>//ww w .j av a 2 s. c om * See http://redis.io/commands/pexpire * * @param key key * @param millis millis * @return Boolean */ public static Boolean pExpire(byte[] key, long millis) { return redisTemplate.execute(new RedisCallback<Boolean>() { @Override public Boolean doInRedis(RedisConnection redis) throws DataAccessException { return redis.pExpire(key, millis); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Set time to live for given {@code key} in seconds. * <p>//from w w w . j ava 2 s.co m * See http://redis.io/commands/expire * * @param key key * @param seconds seconds * @return Boolean */ public Boolean expire(byte[] key, long seconds) { return redisTemplate.execute(new RedisCallback<Boolean>() { @Override public Boolean doInRedis(RedisConnection redis) throws DataAccessException { return redis.expire(key, seconds); } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Set the expiration for given {@code key} as a {@literal UNIX} timestamp. * <p>/*from w ww. j a va 2 s . co m*/ * See http://redis.io/commands/expireat * * @param key key * @param unixTime unixTime * @return Boolean */ public static Boolean expireAt(byte[] key, long unixTime) { return redisTemplate.execute(new RedisCallback<Boolean>() { @Override public Boolean doInRedis(RedisConnection redis) throws DataAccessException { return redis.expireAt(key, unixTime); } }); }