List of usage examples for org.springframework.data.redis.core RedisCallback RedisCallback
RedisCallback
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Increment value of {@code key} by {@code value}. * <p>//from w w w.j a v a 2 s . c om * See http://redis.io/commands/incrbyfloat * * @param key must not be {@literal null}. * @param value value * @return Double */ public static Double incrBy(byte[] key, double value) { return redisTemplate.execute(new RedisCallback<Double>() { @Override public Double doInRedis(RedisConnection redis) throws DataAccessException { return redis.incrBy(key, value); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Increment value of {@code key} by {@code value}. * <p>/*from w w w . j a v a 2s . c om*/ * See http://redis.io/commands/incrby * * @param key must not be {@literal null}. * @param value value * @return Long */ public Long incrBy(byte[] key, long value) { return redisTemplate.execute(new RedisCallback<Long>() { @Override public Long doInRedis(RedisConnection redis) throws DataAccessException { return redis.incrBy(key, value); } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Decrement value of {@code key} by 1.//from w w w . j a va2s . c om * <p> * See http://redis.io/commands/decr * * @param key must not be {@literal null}. * @return Long */ public static Long decr(byte[] key) { return redisTemplate.execute(new RedisCallback<Long>() { @Override public Long doInRedis(RedisConnection redis) throws DataAccessException { return redis.decr(key); } }); }
From source file:org.shareok.data.redis.server.RepoServerDaoImpl.java
@Override public List<RepoServer> getServerObjList(final Collection<String> serverIds) { final List<RepoServer> serverList = new ArrayList<>(); final ApplicationContext context = new ClassPathXmlApplicationContext("redisContext.xml"); try {/* w w w.j av a 2s. co m*/ List<Object> results = redisTemplate.executePipelined(new RedisCallback<Object>() { public Object doInRedis(RedisConnection connection) throws DataAccessException { for (String idStr : serverIds) { int id = Integer.parseInt(idStr); BoundHashOperations<String, String, String> serverOps = redisTemplate .boundHashOps(RedisUtil.getServerQueryKey(id)); if (null != serverOps) { RepoServer server = new RepoServer(); int repoType = Integer.parseInt(serverOps.get("repoType")); server.setServerId(id); server.setServerName(serverOps.get("serverName")); server.setPort(Integer.parseInt(serverOps.get("port"))); server.setProxyPort(Integer.parseInt(serverOps.get("proxyPort"))); server.setTimeout(Integer.parseInt(serverOps.get("timeout"))); server.setHost(serverOps.get("host")); server.setProxyHost(serverOps.get("proxyHost")); server.setUserName(serverOps.get("userName")); server.setProxyUserName(serverOps.get("proxyUserName")); server.setPassword(serverOps.get("password")); server.setProxyPassword(serverOps.get("proxyPassword")); server.setPassPhrase(serverOps.get("passPhrase")); server.setRsaKey(serverOps.get("rsaKey")); server.setRepoType(repoType); server.setAddress(serverOps.get("address")); server = serverDaoHelper.getRepoServerDaoByRepoType(repoType) .loadServerParametersByRepoType(server, serverOps); serverList.add(server); } } return null; } }); return serverList; } catch (Exception ex) { logger.error("Cannot get the server list from the server ID collection.", ex); } return null; }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Increment value of {@code key} by {@code value}. * <p>//from w w w .jav a 2 s . c om * See http://redis.io/commands/incrbyfloat * * @param key must not be {@literal null}. * @param value value * @return Double */ public Double incrBy(byte[] key, double value) { return redisTemplate.execute(new RedisCallback<Double>() { @Override public Double doInRedis(RedisConnection redis) throws DataAccessException { return redis.incrBy(key, value); } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Increment value of {@code key} by {@code value}. * <p>/*from w w w . java2 s . c om*/ * See http://redis.io/commands/decrby * * @param key must not be {@literal null}. * @param value value * @return Long */ public static Long decrBy(byte[] key, long value) { return redisTemplate.execute(new RedisCallback<Long>() { @Override public Long doInRedis(RedisConnection redis) throws DataAccessException { return redis.decrBy(key, value); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Decrement value of {@code key} by 1./*from w w w . ja v a2 s.c o m*/ * <p> * See http://redis.io/commands/decr * * @param key must not be {@literal null}. * @return Long */ public Long decr(byte[] key) { return redisTemplate.execute(new RedisCallback<Long>() { @Override public Long doInRedis(RedisConnection redis) throws DataAccessException { return redis.decr(key); } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Append a {@code value} to {@code key}. * <p>/*from www .ja v a 2 s .c o m*/ * See http://redis.io/commands/append * * @param key must not be {@literal null}. * @param value value * @return Long */ public static Long append(byte[] key, byte[] value) { return redisTemplate.execute(new RedisCallback<Long>() { @Override public Long doInRedis(RedisConnection redis) throws DataAccessException { return redis.append(key, value); } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * Increment value of {@code key} by {@code value}. * <p>/*from w ww . j av a 2s .c o m*/ * See http://redis.io/commands/decrby * * @param key must not be {@literal null}. * @param value value * @return Long */ public Long decrBy(byte[] key, long value) { return redisTemplate.execute(new RedisCallback<Long>() { @Override public Long doInRedis(RedisConnection redis) throws DataAccessException { return redis.decrBy(key, value); } }); }
From source file:com.zxy.commons.cache.RedisUtils.java
/** * Get a substring of value of {@code key} between {@code begin} and {@code end}. * <p>/*ww w. j av a2 s . c om*/ * See http://redis.io/commands/getrange * * @param key must not be {@literal null}. * @param begin begin * @param end end * @return byte[] */ public static byte[] getRange(byte[] key, long begin, long end) { return redisTemplate.execute(new RedisCallback<byte[]>() { @Override public byte[] doInRedis(RedisConnection redis) throws DataAccessException { return redis.getRange(key, begin, end); } }); }