lookupValue = jedisCommand.get(key); break; lookupValue = jedisCommand.lpop(key); break; lookupValue = jedisCommand.hget(additionalKey, key); break; lookupValue = jedisCommand.scard(key); break; lookupValue = jedisCommand.zscore(additionalKey, key); break; lookupValue = jedisCommand.pfcount(key); break; lookupValue = jedisCommand.geopos(additionalKey, key); break;
jedisCommand.set(key, value); break; jedisCommand.rpush(key, value); break; jedisCommand.hset(additionalKey, key, value); break; jedisCommand.sadd(key, value); break; jedisCommand.zadd(additionalKey, Double.valueOf(value), key); break; jedisCommand.pfadd(key, value); break; jedisCommand.geoadd(additionalKey, longitude, latitude, key); break;
public Long del(String key) { return dynoClient.del(key); }
public String get(String key) { return dynoClient.get(key); }
public String set(String key, String value) { String retVal = dynoClient.set(key, value); return retVal; }
private void deleteInternal(RedisClientDelegate delegate, ExecutionType type, String id) { delegate.withCommandsClient(c -> { String key = executionKey(type, id); try { String application = c.hget(key, "application"); String appKey = appKey(type, application); c.srem(appKey, id); c.srem(allBufferedExecutionsKey(type), id); if (type == PIPELINE) { String pipelineConfigId = c.hget(key, "pipelineConfigId"); c.zrem(executionsByPipelineKey(pipelineConfigId), id); } } catch (ExecutionNotFoundException ignored) { // do nothing } finally { c.del(key); c.srem(alljobsKey(type), id); } }); }
@Override public Object get(Object key) throws CacheException { IRedisCommandsHolder _holder = null; try { _holder = __redis.getDefaultCommandsHolder(); String _cacheKey = __doSerializeKey(key); Object _cacheValue; if (__storageWithSet) { _cacheValue = __doUnserializeValue(_holder.getCommands().hget(__cacheName, _cacheKey)); if (!__disabledSubscribeExpired && _cacheValue != null && !_holder.getCommands().exists(__cacheName.concat(__separator).concat(_cacheKey))) { remove(key); } } else { _cacheValue = __doUnserializeValue(_holder.getCommands().get(__cacheName.concat(__separator).concat(_cacheKey))); } return _cacheValue; } catch (Exception e) { throw new CacheException(RuntimeUtils.unwrapThrow(e)); } finally { if (_holder != null) { _holder.release(); } } }
@Override public boolean setTimeout(String messageId, long timeout) { return execute("setTimeout", "(a shard in) " + queueName, () -> { String json = nonQuorumConn.hget(messageStoreKey, messageId); if(json == null) { return false; } Message message = om.readValue(json, Message.class); message.setTimeout(timeout); for (String shard : allShards) { String queueShard = getQueueShardKey(queueName, shard); Double score = quorumConn.zscore(queueShard, messageId); if(score != null) { double priorityd = message.getPriority() / 100; double newScore = Long.valueOf(clock.millis() + timeout).doubleValue() + priorityd; ZAddParams params = ZAddParams.zAddParams().xx(); quorumConn.zadd(queueShard, newScore, messageId, params); json = om.writeValueAsString(message); quorumConn.hset(messageStoreKey, message.getId(), json); return true; } } return false; }); }
public String hget(String key, String field) { return dynoClient.hget(key, field); }
public Long hset(String key, String field, String value) { Long retVal = dynoClient.hset(key, field, value); return retVal; }
found = jedisCommand.exists(key); break; found = jedisCommand.sismember(additionalKey, key); break; found = jedisCommand.hexists(additionalKey, key); break; found = jedisCommand.zrank(additionalKey, key) != null; break; found = jedisCommand.pfcount(key) > 0; break; List<GeoCoordinate> geopos = jedisCommand.geopos(additionalKey, key); found = (geopos != null && geopos.size() > 0); break;
public Long zadd(String key, double score, String member) { Long retVal = dynoClient.zadd(key, score, member); return retVal; }
public Map<String, String> hgetAll(String key) { return call(jedis -> jedis.hgetAll(key), Collections.<String, String>emptyMap()); }
public Long hdel(String key, String... fields) { logger.trace("hdel {} {}", key, fields[0]); return dynoClient.hdel(key, fields); }
@Override public boolean remove(String messageId) { Stopwatch sw = monitor.remove.start(); try { return execute("remove", "(a shard in) " + queueName, () -> { for (String shard : allShards) { String unackShardKey = getUnackKey(queueName, shard); quorumConn.zrem(unackShardKey, messageId); String queueShardKey = getQueueShardKey(queueName, shard); Long removed = quorumConn.zrem(queueShardKey, messageId); Long msgRemoved = quorumConn.hdel(messageStoreKey, messageId); if (removed > 0 && msgRemoved > 0) { return true; } } return false; }); } finally { sw.stop(); } }
@Override public boolean hasExecution(@Nonnull ExecutionType type, @Nonnull String id) { return redisClientDelegate.withCommandsClient(c -> { return c.exists(executionKey(type, id)); }); }
@Override public List<String> push(final List<Message> messages) { Stopwatch sw = monitor.start(monitor.push, messages.size()); try { execute("push", "(a shard in) " + queueName, () -> { for (Message message : messages) { String json = om.writeValueAsString(message); quorumConn.hset(messageStoreKey, message.getId(), json); double priority = message.getPriority() / 100.0; double score = Long.valueOf(clock.millis() + message.getTimeout()).doubleValue() + priority; String shard = shardingStrategy.getNextShard(allShards, message); String queueShard = getQueueShardKey(queueName, shard); quorumConn.zadd(queueShard, score, message.getId()); } return messages; }); return messages.stream().map(msg -> msg.getId()).collect(Collectors.toList()); } finally { sw.stop(); } }