本文整理了Java中redis.clients.jedis.Pipeline.psetex()
方法的一些代码示例,展示了Pipeline.psetex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Pipeline.psetex()
方法的具体详情如下:
包路径:redis.clients.jedis.Pipeline
类名称:Pipeline
方法名:psetex
暂无
代码示例来源:origin: alibaba/jetcache
@Override
protected CacheResult do_PUT_ALL(Map<? extends K, ? extends V> map, long expireAfterWrite, TimeUnit timeUnit) {
if (map == null) {
return CacheResult.FAIL_ILLEGAL_ARGUMENT;
}
try (Jedis jedis = pool.getResource()) {
int failCount = 0;
List<Response<String>> responses = new ArrayList<>();
Pipeline p = jedis.pipelined();
for (Map.Entry<? extends K, ? extends V> en : map.entrySet()) {
CacheValueHolder<V> holder = new CacheValueHolder(en.getValue(), timeUnit.toMillis(expireAfterWrite));
Response<String> resp = p.psetex(buildKey(en.getKey()), timeUnit.toMillis(expireAfterWrite), valueEncoder.apply(holder));
responses.add(resp);
}
p.sync();
for (Response<String> resp : responses) {
if(!"OK".equals(resp.get())){
failCount++;
}
}
return failCount == 0 ? CacheResult.SUCCESS_WITHOUT_MSG :
failCount == map.size() ? CacheResult.FAIL_WITHOUT_MSG : CacheResult.PART_SUCCESS_WITHOUT_MSG;
} catch (Exception ex) {
logError("PUT_ALL", "map(" + map.size() + ")", 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!");
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: com.netflix.spinnaker.kork/kork-jedis
@Override
@Deprecated
public Response<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 Response<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 Response<String> psetex(byte[] key, long milliseconds, byte[] value) {
String command = "psetex";
return instrumented(command, payloadSize(value), () -> delegated.psetex(key, milliseconds, value));
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public Response<String> psetex(String key, long milliseconds, String value) {
String command = "psetex";
return instrumented(command, payloadSize(value), () -> delegated.psetex(key, milliseconds, value));
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-io-redis
private void writeUsingSetCommand(KV<String, String> record, Long expireTime) {
String key = record.getKey();
String value = record.getValue();
if (expireTime != null) {
pipeline.psetex(key, expireTime, value);
} else {
pipeline.set(key, value);
}
}
代码示例来源: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!");
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: apache/servicemix-bundles
@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);
}
}
内容来源于网络,如有侵权,请联系作者删除!