@Override public boolean add(E e, double score) { Boolean result = boundZSetOps.add(e, score); checkResult(result); return result; }
private void doIncrementOrOverwrite(BoundZSetOperations<String, Object> ops, Object object, Double score, boolean increment) { if (increment) { ops.incrementScore(object, score); } else { ops.add(object, score); } }
protected void prepareZset(RedisConnectionFactory connectionFactory) { StringRedisTemplate redisTemplate = createStringRedisTemplate(connectionFactory); redisTemplate.delete("presidents"); BoundZSetOperations<String, String> ops = redisTemplate.boundZSetOps("presidents"); ops.add("John Adams", 18); ops.add("Barack Obama", 21); ops.add("Thomas Jefferson", 19); ops.add("John Quincy Adams", 19); ops.add("Zachary Taylor", 19); ops.add("Theodore Roosevelt", 20); ops.add("Woodrow Wilson", 20); ops.add("George W. Bush", 21); ops.add("Franklin D. Roosevelt", 20); ops.add("Ronald Reagan", 20); ops.add("William J. Clinton", 20); ops.add("Abraham Lincoln", 19); ops.add("George Washington", 18); }
private void doIncrementOrOverwrite(BoundZSetOperations<String, Object> ops, Object object, Double score, boolean increment) { if (increment) { ops.incrementScore(object, score); } else { ops.add(object, score); } }
@Override public boolean add(E e, double score) { Boolean result = boundZSetOps.add(e, score); checkResult(result); return result; }
@Override public boolean add(E e, double score) { Boolean result = boundZSetOps.add(e, score); checkResult(result); return result; }
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 Notifier notify( JobConfiguration id, NotificationLevel level, String message, boolean completed ) { if ( id != null && !(level != null && level.isOff()) ) { Notification notification = new Notification( level, id.getJobType(), new Date(), message, completed ); String notificationKey = generateNotificationKey( id.getJobType(), id.getUid() ); String notificationOrderKey = generateNotificationOrderKey( id.getJobType() ); Date now = new Date(); try { if ( redisTemplate.boundZSetOps( notificationOrderKey ).zCard() >= MAX_POOL_TYPE_SIZE ) { Set<String> deleteKeys = redisTemplate.boundZSetOps( notificationOrderKey ).range( 0, 0 ); redisTemplate.delete( deleteKeys ); redisTemplate.boundZSetOps( notificationOrderKey ).removeRange( 0, 0 ); } redisTemplate.boundZSetOps( notificationKey ).add( objectMapper.writeValueAsString( notification ), now.getTime() ); redisTemplate.boundZSetOps( notificationOrderKey ).add( id.getUid(), now.getTime() ); } catch ( JsonProcessingException ex ) { log.warn( String.format( NOTIFIER_ERROR, ex.getMessage() ) ); } log.info( notification ); } return this; }
protected void addOps(final EmailSchedulingData emailSchedulingData) { final String orderingKey = orderingKey(emailSchedulingData); final String valueKey = emailSchedulingData.getId(); final double score = calculateScore(emailSchedulingData); BoundZSetOperations<String, String> orderingZSetOps = orderingTemplate.boundZSetOps(orderingKey); orderingZSetOps.add(valueKey, score); orderingZSetOps.persist(); BoundValueOperations<String, EmailSchedulingData> valueValueOps = valueTemplate.boundValueOps(valueKey); valueValueOps.set(emailSchedulingData); valueValueOps.persist(); }
protected void addOps(final EmailSchedulingData emailSchedulingData) { final String orderingKey = orderingKey(emailSchedulingData); final String valueKey = emailSchedulingData.getId(); final double score = calculateScore(emailSchedulingData); BoundZSetOperations<String, String> orderingZSetOps = orderingTemplate.boundZSetOps(orderingKey); orderingZSetOps.add(valueKey, score); orderingZSetOps.persist(); BoundValueOperations<String, EmailSchedulingData> valueValueOps = valueTemplate.boundValueOps(valueKey); valueValueOps.set(emailSchedulingData); valueValueOps.persist(); }
Date now = new Date(); redisTemplate.boundZSetOps( summaryOrderKey ).add( id.getUid(), now.getTime() );