redis.clients.jedis.JedisCommands.get()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中redis.clients.jedis.JedisCommands.get()方法的一些代码示例,展示了JedisCommands.get()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JedisCommands.get()方法的具体详情如下:
包路径:redis.clients.jedis.JedisCommands
类名称:JedisCommands
方法名:get

JedisCommands.get介绍

暂无

代码示例

代码示例来源:origin: Netflix/conductor

public String get(String key) {
  return dynoClient.get(key);
}

代码示例来源:origin: mpusher/mpush

/**
 * @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);
}

代码示例来源:origin: apache/storm

lookupValue = jedisCommand.get(key);
break;

代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence

public String get(String key) {
  return dynoClient.get(key);
}

代码示例来源:origin: com.netflix.spinnaker.clouddriver/cats-dynomite

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);
 }
}

代码示例来源:origin: com.netflix.spinnaker.echo/echo-pubsub-core

private Boolean messageComplete(String messageKey, String value) {
 return redisClientDelegate.withCommandsClient(c -> {
  return getCRC32(value).equals(c.get(messageKey));
 });
}

代码示例来源:origin: wyh-spring-ecosystem-student/spring-boot-student

/**
 * 获取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;
  });
}

代码示例来源:origin: com.y3tu/y3tu-tool-web

/**
 * 获取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;
  });
}

代码示例来源:origin: com.github.mpusher/mpush-cache

/**
 * @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);
}

代码示例来源:origin: com.github.bingoohuang/delayqueue

@Override public void load(TaskItem taskItem) {
    String json = jedisCommands.get("delayqueue:" + taskItem.getTaskId());
    taskItem.setResult(json);
  }
}

代码示例来源:origin: com.netflix.spinnaker.clouddriver/clouddriver-core

@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;
}

代码示例来源:origin: com.gitee.zhaohuihua/bdp-general-svc

/** {@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);
}

代码示例来源:origin: com.gitee.qdbp/qdbp-general-biz

/** {@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);
}

代码示例来源:origin: com.gitee.zhaohuihua/bdp-general-svc

/** {@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);
}

代码示例来源:origin: com.gitee.qdbp/qdbp-general-biz

/** {@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);
}

代码示例来源:origin: com.github.ddth/ddth-dlock-core

/**
 * 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);
  }
}

代码示例来源:origin: com.netflix.spinnaker.orca/orca-redis

@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)
  );
 });
}

代码示例来源:origin: com.netflix.spinnaker.orca/orca-redis

@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)
  );
 });
}

代码示例来源:origin: com.netflix.spinnaker.clouddriver/cats-dynomite

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;
   });
 });
}

代码示例来源:origin: vakinge/jeesuite-libs

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);
  }
  
}

相关文章

微信公众号

最新文章

更多