public String get(String key) { return dynoClient.get(key); }
/** * @param key * @param clazz * @return */ @SuppressWarnings("unchecked") public <T> T get(String key, Class<T> clazz) { String value = call(jedis -> jedis.get(key), null); if (value == null) return null; if (clazz == String.class) return (T) value; return Jsons.fromJson(value, clazz); }
lookupValue = jedisCommand.get(key); break;
public String get(String key) { return dynoClient.get(key); }
private void ttlLock(JedisCommands client, String agentType, long newTtl) { String response = client.get(agentType); if (nodeIdentity.getNodeIdentity().equals(response)) { client.pexpireAt(agentType, System.currentTimeMillis() + newTtl); } }
private Boolean messageComplete(String messageKey, String value) { return redisClientDelegate.withCommandsClient(c -> { return getCRC32(value).equals(c.get(messageKey)); }); }
/** * 获取redis里面的值 * * @param key key * @param aClass class * @return T */ private <T> T get(final String key, Class<T> aClass) { Assert.isTrue(!StringUtils.isEmpty(key), "key不能为空"); return redisTemplate.execute((RedisConnection connection) -> { Object nativeConnection = connection.getNativeConnection(); Object result = null; if (nativeConnection instanceof JedisCommands) { result = ((JedisCommands) nativeConnection).get(key); } return (T) result; }); }
/** * 获取redis里面的值 * * @param key key * @param aClass class * @return T */ private <T> T get(final String key, Class<T> aClass) { Assert.isTrue(!StringUtils.isEmpty(key), "key不能为空"); return redisTemplate.execute((RedisConnection connection) -> { Object nativeConnection = connection.getNativeConnection(); Object result = null; if (nativeConnection instanceof JedisCommands) { result = ((JedisCommands) nativeConnection).get(key); } return (T) result; }); }
/** * @param key * @param clazz * @return */ @SuppressWarnings("unchecked") public <T> T get(String key, Class<T> clazz) { String value = call(jedis -> jedis.get(key), null); if (value == null) return null; if (clazz == String.class) return (T) value; return Jsons.fromJson(value, clazz); }
@Override public void load(TaskItem taskItem) { String json = jedisCommands.get("delayqueue:" + taskItem.getTaskId()); taskItem.setResult(json); } }
@Override public Task getByClientRequestId(String clientRequestId) { final String clientRequestKey = getClientRequestKey(clientRequestId); String existingTask = retry(() -> redisClientDelegate.withCommandsClient(client -> { return client.get(clientRequestKey); }), format("Getting task by client request ID %s", clientRequestId)); if (existingTask == null) { if (redisClientDelegatePrevious.isPresent()) { try { existingTask = redisClientDelegatePrevious.get().withCommandsClient(client -> { return client.get(clientRequestKey); }); } catch (Exception e) { // Failed to hit old redis, let's not blow up on that existingTask = null; } } } if (existingTask != null) { return get(existingTask); } return null; }
/** {@inheritDoc} **/ @Override protected <T> List<T> list(String key, String subkey, Class<T> clazz) { JedisCommands jedis = this.getInstanceByKey(key); String string = jedis.get(concat(key, subkey)); return deserializeList(string, clazz); }
/** {@inheritDoc} **/ @Override public <T> T get(String key, String subkey, Class<T> clazz) { JedisCommands jedis = this.getInstanceByKey(key); String string = jedis.get(concat(key, subkey)); return deserializeValue(string, clazz); }
/** {@inheritDoc} **/ @Override protected <T> T get(String key, String subkey, Class<T> clazz) { JedisCommands jedis = this.getInstanceByKey(key); String string = jedis.get(concat(key, subkey)); return deserializeValue(string, clazz); }
/** {@inheritDoc} **/ @Override public <T> List<T> list(String key, String subkey, Class<T> clazz) { JedisCommands jedis = this.getInstanceByKey(key); String string = jedis.get(concat(key, subkey)); return deserializeList(string, clazz); }
/** * Update current lock's holder info. * * @param jedisCommands * @since 0.1.1 */ protected void updateLockHolder(JedisCommands jedisCommands) { String key = getName(); String clientId = jedisCommands.get(key); setClientId(clientId); if (!StringUtils.isBlank(clientId)) { Long ttl = jedisCommands.pttl(key); if (ttl != null && ttl.longValue() != -2) { setTimestampExpiry(ttl.longValue() != -1 ? System.currentTimeMillis() + ttl.longValue() : Integer.MAX_VALUE); } else { setTimestampExpiry(Integer.MAX_VALUE); } } else { setTimestampExpiry(0); } }
@Override public @Nonnull Execution retrieveOrchestrationForCorrelationId( @Nonnull String correlationId) throws ExecutionNotFoundException { String key = format("correlation:%s", correlationId); return getRedisDelegate(key).withCommandsClient(correlationRedis -> { String orchestrationId = correlationRedis.get(key); if (orchestrationId != null) { Execution orchestration = retrieveInternal( getRedisDelegate(orchestrationKey(orchestrationId)), ORCHESTRATION, orchestrationId); if (!orchestration.getStatus().isComplete()) { return orchestration; } correlationRedis.del(key); } throw new ExecutionNotFoundException( format("No Orchestration found for correlation ID %s", correlationId) ); }); }
@Nonnull @Override public Execution retrievePipelineForCorrelationId(@Nonnull String correlationId) throws ExecutionNotFoundException { String key = format("pipelineCorrelation:%s", correlationId); return getRedisDelegate(key).withCommandsClient(correlationRedis -> { String pipelineId = correlationRedis.get(key); if (pipelineId != null) { Execution pipeline = retrieveInternal( getRedisDelegate(pipelineKey(pipelineId)), PIPELINE, pipelineId ); if (!pipeline.getStatus().isComplete()) { return pipeline; } correlationRedis.del(key); } throw new ExecutionNotFoundException( format("No Pipeline found for correlation ID %s", correlationId) ); }); }
private boolean acquireRunKey(String agentType, long timeout) { // This isn't as safe as the vanilla Redis impl because the call isn't atomic, but it's the best we can do until // dynomite adds support for `String set(String key, String value, String nxxx, String expx, long time)` (which // they are working on). String identity = nodeIdentity.getNodeIdentity(); return redisClientDelegate.withCommandsClient(client -> { return Failsafe .with(ACQUIRE_LOCK_RETRY_POLICY) .get(() -> { String response = client.get(agentType); if (response == null && client.setnx(agentType, identity) == 1) { client.pexpireAt(agentType, System.currentTimeMillis() + timeout); return true; } if (client.ttl(agentType) == -1) { log.warn("Detected potential deadlocked agent, removing lock key: " + agentType); client.del(agentType); } return false; }); }); }
public String get() { String value = Level1CacheSupport.getInstance().get(key); if(value != null)return value; try { value = getJedisCommands(groupName).get(key); return value; } finally { getJedisProvider(groupName).release(); // Level1CacheSupport.getInstance().set(key, value); } }