@Override public Long increment(String key, long delta) { return stringRedisTemplate.opsForValue().increment(key,delta); } }
@Override public String get(String key) { return stringRedisTemplate.opsForValue().get(key); }
@Override public void set(String key, String value) { stringRedisTemplate.opsForValue().set(key, value); }
@Override public void add(String token) { Objects.requireNonNull(token); Long size = redisTemplate.opsForList().size(REDIS_PREFIX); redisTemplate.opsForList().leftPush(REDIS_PREFIX, token); redisTemplate.expire(REDIS_PREFIX, 20, TimeUnit.MINUTES); if (Objects.nonNull(size) && size > 3) { redisTemplate.opsForList().rightPop(REDIS_PREFIX); } }
@Override public void createGroup(String groupId) { redisTemplate.opsForList().leftPush(REDIS_PREFIX + groupId, "tx.starter"); redisTemplate.expire(REDIS_PREFIX + groupId, managerConfig.getDtxTime() + 10000, TimeUnit.MILLISECONDS); }
@Override public void clear() { redisTemplate.delete(REDIS_PREFIX); } }
@Override public void remove(String key) { stringRedisTemplate.delete(key); }
@Override public boolean expire(String key, long expire) { return stringRedisTemplate.expire(key, expire, TimeUnit.SECONDS); }
@Override public V rightPopAndLeftPush(K sourceKey, K destinationKey, long timeout, TimeUnit unit) { int tm = (int) TimeoutUtils.toSeconds(timeout, unit); byte[] rawDestKey = rawKey(destinationKey); return execute(new ValueDeserializingRedisCallback(sourceKey) { @Override protected byte[] inRedis(byte[] rawSourceKey, RedisConnection connection) { return connection.bRPopLPush(tm, rawSourceKey, rawDestKey); } }, true); }
@Override public V leftPop(K key, long timeout, TimeUnit unit) { int tm = (int) TimeoutUtils.toSeconds(timeout, unit); return execute(new ValueDeserializingRedisCallback(key) { @Override protected byte[] inRedis(byte[] rawKey, RedisConnection connection) { List<byte[]> lPop = connection.bLPop(tm, rawKey); return (CollectionUtils.isEmpty(lPop) ? null : lPop.get(1)); } }, true); }
public String get(String key) { return this.stringRedisTemplate.opsForValue().get(key); }
@Override public V rightPop(K key, long timeout, TimeUnit unit) { int tm = (int) TimeoutUtils.toSeconds(timeout, unit); return execute(new ValueDeserializingRedisCallback(key) { @Override protected byte[] inRedis(byte[] rawKey, RedisConnection connection) { List<byte[]> bRPop = connection.bRPop(tm, rawKey); return (CollectionUtils.isEmpty(bRPop) ? null : bRPop.get(1)); } }, true); }
public String get(String key) { return this.stringRedisTemplate.opsForValue().get(key); }
public String get(String key) { return this.stringRedisTemplate.opsForValue().get(key); }
public String get(String key) { return this.stringRedisTemplate.opsForValue().get(key); }
public String get(String key) { return this.stringRedisTemplate.opsForValue().get(key); }