/** * Constructs a new {@link DefaultBoundValueOperations} instance. * * @param key * @param operations */ DefaultBoundValueOperations(K key, RedisOperations<K, V> operations) { super(key, operations); this.ops = operations.opsForValue(); }
public void setValue(Object value) { if (value instanceof RedisOperations) { super.setValue(((RedisOperations) value).opsForValue()); } else { throw new IllegalArgumentException("Editor supports only conversion of type " + RedisOperations.class); } } }
private RedisAtomicInteger(String redisCounter, RedisOperations<String, Integer> template, @Nullable Integer initialValue) { Assert.hasText(redisCounter, "a valid counter name is required"); Assert.notNull(template, "a valid template is required"); Assert.notNull(template.getKeySerializer(), "a valid key serializer in template is required"); Assert.notNull(template.getValueSerializer(), "a valid value serializer in template is required"); this.key = redisCounter; this.generalOps = template; this.operations = generalOps.opsForValue(); if (initialValue == null) { initializeIfAbsent(); } else { set(initialValue); } }
private RedisAtomicLong(String redisCounter, RedisOperations<String, Long> template, @Nullable Long initialValue) { Assert.hasText(redisCounter, "a valid counter name is required"); Assert.notNull(template, "a valid template is required"); Assert.notNull(template.getKeySerializer(), "a valid key serializer in template is required"); Assert.notNull(template.getValueSerializer(), "a valid value serializer in template is required"); this.key = redisCounter; this.generalOps = template; this.operations = generalOps.opsForValue(); if (initialValue == null) { initializeIfAbsent(); } else { set(initialValue); } }
private RedisAtomicDouble(String redisCounter, RedisOperations<String, Double> template, @Nullable Double initialValue) { Assert.hasText(redisCounter, "a valid counter name is required"); Assert.notNull(template, "a valid template is required"); Assert.notNull(template.getKeySerializer(), "a valid key serializer in template is required"); Assert.notNull(template.getValueSerializer(), "a valid value serializer in template is required"); this.key = redisCounter; this.generalOps = template; this.operations = generalOps.opsForValue(); if (initialValue == null) { initializeIfAbsent(); } else { set(initialValue); } }
private RedisAtomicDouble(String redisCounter, RedisConnectionFactory factory, @Nullable Double initialValue) { Assert.hasText(redisCounter, "a valid counter name is required"); Assert.notNull(factory, "a valid factory is required"); RedisTemplate<String, Double> redisTemplate = new RedisTemplate<>(); redisTemplate.setKeySerializer(RedisSerializer.string()); redisTemplate.setValueSerializer(new GenericToStringSerializer<>(Double.class)); redisTemplate.setExposeConnection(true); redisTemplate.setConnectionFactory(factory); redisTemplate.afterPropertiesSet(); this.key = redisCounter; this.generalOps = redisTemplate; this.operations = generalOps.opsForValue(); if (initialValue == null) { initializeIfAbsent(); } else { set(initialValue); } }
private RedisAtomicLong(String redisCounter, RedisConnectionFactory factory, @Nullable Long initialValue) { Assert.hasText(redisCounter, "a valid counter name is required"); Assert.notNull(factory, "a valid factory is required"); RedisTemplate<String, Long> redisTemplate = new RedisTemplate<>(); redisTemplate.setKeySerializer(RedisSerializer.string()); redisTemplate.setValueSerializer(new GenericToStringSerializer<>(Long.class)); redisTemplate.setExposeConnection(true); redisTemplate.setConnectionFactory(factory); redisTemplate.afterPropertiesSet(); this.key = redisCounter; this.generalOps = redisTemplate; this.operations = generalOps.opsForValue(); if (initialValue == null) { initializeIfAbsent(); } else { set(initialValue); } }
private RedisAtomicInteger(String redisCounter, RedisConnectionFactory factory, @Nullable Integer initialValue) { RedisTemplate<String, Integer> redisTemplate = new RedisTemplate<>(); redisTemplate.setKeySerializer(RedisSerializer.string()); redisTemplate.setValueSerializer(new GenericToStringSerializer<>(Integer.class)); redisTemplate.setExposeConnection(true); redisTemplate.setConnectionFactory(factory); redisTemplate.afterPropertiesSet(); this.key = redisCounter; this.generalOps = redisTemplate; this.operations = generalOps.opsForValue(); if (initialValue == null) { initializeIfAbsent(); } else { set(initialValue); } }
/** * Constructs a new {@link DefaultBoundValueOperations} instance. * * @param key * @param operations */ DefaultBoundValueOperations(K key, RedisOperations<K, V> operations) { super(key, operations); this.ops = operations.opsForValue(); }
/** * Constructs a new {@link DefaultBoundValueOperations} instance. * * @param key * @param operations */ DefaultBoundValueOperations(K key, RedisOperations<K, V> operations) { super(key, operations); this.ops = operations.opsForValue(); }
public void setValue(Object value) { if (value instanceof RedisOperations) { super.setValue(((RedisOperations) value).opsForValue()); } else { throw new IllegalArgumentException("Editor supports only conversion of type " + RedisOperations.class); } } }
@Override public long getPutTimes() { return StringUtils.toInt(redisOperations.opsForValue().get(new String(putTimeKey))); } }
public void setValue(Object value) { if (value instanceof RedisOperations) { super.setValue(((RedisOperations) value).opsForValue()); } else { throw new IllegalArgumentException("Editor supports only conversion of type " + RedisOperations.class); } } }
@Override public long getTotalTimes() { return StringUtils.toInt(redisOperations.opsForValue().get(new String(totalTimeKey))); }
@Override public long getHitTimes() { return StringUtils.toInt(redisOperations.opsForValue().get(new String(hitTimeKey))); }
public List<Object> execute(RedisOperations operations) throws DataAccessException { operations.multi(); operations.opsForValue().set(sessionKey, session); operations.expire(sessionKey, expireValue.longValue(), TimeUnit.SECONDS); return operations.exec(); } });
public Metric<?> findOne(String metricName) { String redisKey = keyFor(metricName); String raw = this.redisOperations.opsForValue().get(redisKey); return deserialize(redisKey, raw, this.zSetOperations.score(redisKey)); }
public void set(Metric<?> value) { String name = value.getName(); String key = keyFor(name); trackMembership(key); this.zSetOperations.add(key, value.getValue().doubleValue()); String raw = serialize(value); this.redisOperations.opsForValue().set(key, raw); }
@Override public Object execute(RedisOperations operations) throws DataAccessException { operations.multi(); operations.opsForValue().get("test"); operations.delete("test"); operations.opsForValue().set("test", "6"); List<String> rs = operations.exec(); System.out.println(" rs:" + rs.toString()); return rs; } });
public void increment(Delta<?> delta) { String name = delta.getName(); String key = keyFor(name); trackMembership(key); double value = this.zSetOperations.incrementScore(key, delta.getValue().doubleValue()); String raw = serialize(new Metric<Double>(name, value, delta.getTimestamp())); this.redisOperations.opsForValue().set(key, raw); }