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

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

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

Jedis.psetex介绍

[英]PSETEX works exactly like #setex(String,int,String) with the sole difference that the expire time is specified in milliseconds instead of seconds. Time complexity: O(1)
[中]PSETEX的工作原理与#setex(String,int,String)完全相同,唯一的区别是过期时间是以毫秒而不是秒为单位指定的。时间复杂度:O(1)

代码示例

代码示例来源:origin: sohutv/cachecloud

@Override
public String psetex(String key, long milliseconds, String value) {
 Jedis j = getShard(key);
 return j.psetex(key, milliseconds, value);
}

代码示例来源:origin: signalapp/Signal-Server

public void setLastNumber(Optional<String> lastNumber) {
 try (Jedis jedis = jedisPool.getWriteResource()) {
  if (lastNumber.isPresent()) {
   jedis.psetex(LAST_NUMBER_KEY, LAST_NUMBER_TTL_MS, lastNumber.get());
  } else {
   jedis.del(LAST_NUMBER_KEY);
  }
 }
}

代码示例来源:origin: apache/incubator-druid

@Override
public void put(NamedKey key, byte[] value)
{
 totalRequestCount.incrementAndGet();
 try (Jedis jedis = pool.getResource()) {
  jedis.psetex(key.toByteArray(), config.getExpiration(), value);
 }
 catch (JedisException e) {
  errorCount.incrementAndGet();
  log.warn(e, "Exception pushing item to cache");
 }
}

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

@Override
public String psetex(String key, long milliseconds, String value) {
 Jedis jedis = null;
  try {
   jedis = jedisPool.getResource();
   return jedis.psetex(key, milliseconds, value);
  } finally {
   if (jedis != null)
    jedis.close();
  }
}

代码示例来源:origin: alibaba/jetcache

@Override
protected CacheResult do_PUT(K key, V value, long expireAfterWrite, TimeUnit timeUnit) {
  if (key == null) {
    return CacheResult.FAIL_ILLEGAL_ARGUMENT;
  }
  try (Jedis jedis = pool.getResource()) {
    CacheValueHolder<V> holder = new CacheValueHolder(value, timeUnit.toMillis(expireAfterWrite));
    byte[] newKey = buildKey(key);
    String rt = jedis.psetex(newKey, timeUnit.toMillis(expireAfterWrite), valueEncoder.apply(holder));
    if ("OK".equals(rt)) {
      return CacheResult.SUCCESS_WITHOUT_MSG;
    } else {
      return new CacheResult(CacheResultCode.FAIL, rt);
    }
  } catch (Exception ex) {
    logError("PUT", key, ex);
    return new CacheResult(ex);
  }
}

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

@Override
public Boolean pSetEx(byte[] key, long milliseconds, byte[] value) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  return Converters.stringToBoolean(connection.getClusterCommandExecutor()
      .executeCommandOnSingleNode(
          (JedisClusterCommandCallback<String>) client -> client.psetex(key, milliseconds, value),
          connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
      .getValue());
}

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

@Override
public Boolean pSetEx(byte[] key, long milliseconds, byte[] value) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().psetex(key, milliseconds, value),
          Converters.stringToBooleanConverter(), () -> false));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().psetex(key, milliseconds, value),
          Converters.stringToBooleanConverter(), () -> false));
      return null;
    }
    return Converters.stringToBoolean(connection.getJedis().psetex(key, milliseconds, value));
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

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

@SuppressWarnings("deprecation")
@Override
public String psetex(String key, int milliseconds, String value) {
  return jedis.psetex(key, milliseconds, value);
}

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

@Override
 public String execute(Jedis connection) {
  return connection.psetex(key, milliseconds, value);
 }
}.run(key);

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

@Override
public String psetex(String key, long milliseconds, String value) {
  return jedis.psetex(key, milliseconds, value);
}

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

@SuppressWarnings("deprecation")
@Override
public String psetex(String key, int milliseconds, String value) {
  return jedis.psetex(key, milliseconds, value);
}

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

private void setMessageHandled(String messageKey, String identifier, Long retentionDeadlineMillis) {
 try (Jedis resource = jedisPool.getResource()) {
  resource.psetex(messageKey, retentionDeadlineMillis, identifier);
 }
}

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

@Override
public String psetex(final byte[] key, final long milliseconds, final byte[] value) {
 Jedis j = getShard(key);
 return j.psetex(key, milliseconds, value);
}

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

@Override
@Deprecated
public String psetex(byte[] key, int milliseconds, byte[] value) {
 String command = "psetex";
 return instrumented(command, payloadSize(value), () -> delegated.psetex(key, milliseconds, value));
}

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

@Override
@Deprecated
public String psetex(String key, int milliseconds, String value) {
 String command = "psetex";
 return instrumented(command, payloadSize(value), () -> delegated.psetex(key, milliseconds, value));
}

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

@Override
public String psetex(byte[] key, long milliseconds, byte[] value) {
 String command = "psetex";
 return instrumented(command, payloadSize(value), () -> delegated.psetex(key, milliseconds, value));
}

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

public String psetex(byte[] key, int milliseconds, byte[] value) {
  Jedis jedis = getJedis();
  try {
    return jedis.psetex(key, milliseconds, value);
  } finally {Streams.safeClose(jedis);}
}

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

@Override
public String psetex(String key, long milliseconds, String value) {
 String command = "psetex";
 return instrumented(command, payloadSize(value), () -> delegated.psetex(key, milliseconds, value));
}

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

public String psetex(String key, int milliseconds, String value) {
  Jedis jedis = getJedis();
  try {
    return jedis.psetex(key, milliseconds, value);
  } finally {Streams.safeClose(jedis);}
}

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

@Override
public Boolean pSetEx(byte[] key, long milliseconds, byte[] value) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  return Converters.stringToBoolean(connection.getClusterCommandExecutor()
      .executeCommandOnSingleNode(
          (JedisClusterCommandCallback<String>) client -> client.psetex(key, milliseconds, value),
          connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
      .getValue());
}

相关文章

Jedis类方法