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

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

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

Jedis.time介绍

暂无

代码示例

代码示例来源:origin: spinnaker/kayenta

public long getRedisTime() {
 try (Jedis jedis = jedisPool.getResource()) {
  List<String> redisTimeList = jedis.time();
  return Long.parseLong(redisTimeList.get(0)) * 1000 + Long.parseLong(redisTimeList.get(1)) / 1000;
 }
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Long time() {
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().time(), JedisConverters.toTimeConverter()));
      return null;
    }
    if (isQueueing()) {
      transaction(
          connection.newJedisResult(connection.getRequiredTransaction().time(), JedisConverters.toTimeConverter()));
      return null;
    }
    return JedisConverters.toTimeConverter().convert(connection.getJedis().time());
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: tangaiyun/RedisRateLimiter

private String getKeyNameForSecond(Jedis jedis, String keyPrefix) {
  String keyName  = keyPrefix + ":" + jedis.time().get(0);
  return keyName;
}

代码示例来源:origin: mindwind/craft-atom

private Long time0(Jedis j) {
  List<String> l = j.time();
  return Long.parseLong(l.get(0)) * 1000 + Long.parseLong(l.get(1)) / 1000;
}

代码示例来源:origin: tangaiyun/RedisRateLimiter

/**
 *  因为redis访问实际上是单线程的,而且jedis.time()方法返回的时间精度为微秒级,每一个jedis.time()调用耗时应该会超过1微秒,因此我们可以认为每次jedis.time()返回的时间都是唯一且递增的
 */
private long getRedisTime(Jedis jedis) {
  List<String> jedisTime = jedis.time();
  Long currentSecond = Long.parseLong(jedisTime.get(0));
  Long microSecondsElapseInCurrentSecond = Long.parseLong(jedisTime.get(1));
  Long currentTimeInMicroSecond = currentSecond * 1000000 + microSecondsElapseInCurrentSecond;
  return currentTimeInMicroSecond;
}

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

public long getRedisTime() {
 try (Jedis jedis = jedisPool.getResource()) {
  List<String> redisTimeList = jedis.time();
  return Long.parseLong(redisTimeList.get(0)) * 1000 + Long.parseLong(redisTimeList.get(1)) / 1000;
 }
}

代码示例来源:origin: mindwind/craft-atom

private Long microtime0(Jedis j) {
  List<String> l = j.time();
  return Long.parseLong(l.get(0)) * 1000 * 1000 + Long.parseLong(l.get(1));
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public List<String> time() {
 String command = "time";
 return instrumented(command, () -> delegated.time());
}

代码示例来源:origin: tangaiyun/RedisRateLimiter

private String[] getKeyNames(Jedis jedis, String keyPrefix) {
  String[] keyNames = null;
  if (timeUnit == TimeUnit.MINUTES) {
    long index = Long.parseLong(jedis.time().get(0)) / 60;
    String keyName1 = keyPrefix + ":" + (index - 1);
    String keyName2 = keyPrefix + ":" + index;
    keyNames = new String[] { keyName1, keyName2 };
  } else if (timeUnit == TimeUnit.HOURS) {
    long index = Long.parseLong(jedis.time().get(0)) / 3600;
    String keyName1 = keyPrefix + ":" + (index - 1);
    String keyName2 = keyPrefix + ":" + index;
    keyNames = new String[] { keyName1, keyName2 };
  } else if (timeUnit == TimeUnit.DAYS) {
    long index = Long.parseLong(jedis.time().get(0)) / (3600 * 24);
    String keyName1 = keyPrefix + ":" + (index - 1);
    String keyName2 = keyPrefix + ":" + index;
    keyNames = new String[] { keyName1, keyName2 };
  } else {
    throw new java.lang.IllegalArgumentException("Don't support this TimeUnit: " + timeUnit);
  }
  return keyNames;
}

代码示例来源:origin: io.enoa/nosql-redis

default List<String> time() {
  return this.run((jedis, serializer) -> jedis.time());
 }
}

代码示例来源:origin: org.nutz/nutz-integration-jedis

public List<String> time() {
  Jedis jedis = getJedis();
  try {
    return jedis.time();
  } finally {Streams.safeClose(jedis);}
}

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
public Long time() {
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().time(), JedisConverters.toTimeConverter()));
      return null;
    }
    if (isQueueing()) {
      transaction(
          connection.newJedisResult(connection.getRequiredTransaction().time(), JedisConverters.toTimeConverter()));
      return null;
    }
    return JedisConverters.toTimeConverter().convert(connection.getJedis().time());
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Long time() {
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().time(), JedisConverters.toTimeConverter()));
      return null;
    }
    if (isQueueing()) {
      transaction(
          connection.newJedisResult(connection.getRequiredTransaction().time(), JedisConverters.toTimeConverter()));
      return null;
    }
    return JedisConverters.toTimeConverter().convert(connection.getJedis().time());
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

相关文章

Jedis类方法