List of usage examples for org.springframework.data.redis.core RedisCallback RedisCallback
RedisCallback
From source file:com.mauersu.util.redis.DefaultValueOperations.java
public Long increment(K key, final long delta) { final byte[] rawKey = rawKey(key); return execute(new RedisCallback<Long>() { public Long doInRedis(RedisConnection connection) { connection.select(dbIndex);/* w w w . ja v a2 s. c o m*/ return connection.incrBy(rawKey, delta); } }, true); }
From source file:com.mauersu.util.redis.DefaultSetOperations.java
public Set<V> difference(final K key, final Collection<K> otherKeys) { final byte[][] rawKeys = rawKeys(key, otherKeys); Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() { public Set<byte[]> doInRedis(RedisConnection connection) { connection.select(dbIndex);/* www . j a v a 2 s . c o m*/ return connection.sDiff(rawKeys); } }, true); return deserializeValues(rawValues); }
From source file:io.gravitee.repository.redis.management.internal.impl.MembershipRedisRepositoryImpl.java
@Override public void delete(RedisMembership membership) { redisTemplate.executePipelined(new RedisCallback<Object>() { @Override/*from w w w . j a v a 2 s . co m*/ public Object doInRedis(RedisConnection connection) throws DataAccessException { redisTemplate.opsForHash().delete(REDIS_KEY, getMembershipKey(membership)); redisTemplate.opsForSet().remove(getMembershipByReferenceKey(membership), getMembershipKey(membership)); redisTemplate.opsForSet().remove(getMembershipByUserKey(membership), getMembershipKey(membership)); return null; } }); }
From source file:com.mauersu.util.redis.DefaultHashOperations.java
public Boolean hasKey(K key, Object hashKey) { final byte[] rawKey = rawKey(key); final byte[] rawHashKey = rawHashKey(hashKey); return execute(new RedisCallback<Boolean>() { public Boolean doInRedis(RedisConnection connection) { connection.select(dbIndex);/*from w w w .j a v a2 s.c om*/ return connection.hExists(rawKey, rawHashKey); } }, true); }
From source file:com.mauersu.util.redis.DefaultZSetOperations.java
public Long add(K key, Set<TypedTuple<V>> tuples) { final byte[] rawKey = rawKey(key); final Set<Tuple> rawValues = rawTupleValues(tuples); return execute(new RedisCallback<Long>() { public Long doInRedis(RedisConnection connection) { connection.select(dbIndex);/* w w w.ja va2 s .c o m*/ return connection.zAdd(rawKey, rawValues); } }, true); }
From source file:com.mauersu.util.redis.DefaultValueOperations.java
public Double increment(K key, final double delta) { final byte[] rawKey = rawKey(key); return execute(new RedisCallback<Double>() { public Double doInRedis(RedisConnection connection) { connection.select(dbIndex);/*from ww w . ja v a2 s .c o m*/ return connection.incrBy(rawKey, delta); } }, true); }
From source file:com.mauersu.util.redis.DefaultListOperations.java
public Long leftPush(K key, V value) { final byte[] rawKey = rawKey(key); final byte[] rawValue = rawValue(value); return execute(new RedisCallback<Long>() { public Long doInRedis(RedisConnection connection) { connection.select(dbIndex);//from ww w.j av a 2 s . c om return connection.lPush(rawKey, rawValue); } }, true); }
From source file:com.zxy.commons.cache.RedisCache.java
@Override public void put(Object key, Object value) { redisTemplate.execute(new RedisCallback<Long>() { public Long doInRedis(RedisConnection connection) throws DataAccessException { byte[] keyb = SerializationUtils.serialize(key); byte[] valueb = SerializationUtils.serialize(value); connection.set(keyb, valueb); if (expires > 0) { connection.expire(keyb, expires); }/* ww w . j a v a2s.co m*/ return 1L; } }); }
From source file:grails.plugin.cache.redis.GrailsRedisCache.java
@SuppressWarnings("unchecked") @Override/*from ww w . j a v a 2 s .c om*/ public ValueWrapper get(final Object key) { return (ValueWrapper) template.execute(new RedisCallback<ValueWrapper>() { public ValueWrapper doInRedis(RedisConnection connection) throws DataAccessException { waitForLock(connection); byte[] bs = connection.get(computeKey(key)); return (bs == null ? null : newValueWrapper(template.getValueSerializer().deserialize(bs))); } }, true); }
From source file:com.mauersu.util.redis.DefaultZSetOperations.java
public Double incrementScore(K key, V value, final double delta) { final byte[] rawKey = rawKey(key); final byte[] rawValue = rawValue(value); return execute(new RedisCallback<Double>() { public Double doInRedis(RedisConnection connection) { connection.select(dbIndex);/* ww w . ja v a 2s . co m*/ return connection.zIncrBy(rawKey, delta, rawValue); } }, true); }