本文整理了Java中redis.clients.jedis.Transaction.expire()
方法的一些代码示例,展示了Transaction.expire()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transaction.expire()
方法的具体详情如下:
包路径:redis.clients.jedis.Transaction
类名称:Transaction
方法名:expire
暂无
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Boolean expire(byte[] key, long seconds) {
Assert.notNull(key, "Key must not be null!");
if (seconds > Integer.MAX_VALUE) {
return pExpire(key, TimeUnit.SECONDS.toMillis(seconds));
}
try {
if (isPipelined()) {
pipeline(connection.newJedisResult(connection.getRequiredPipeline().expire(key, (int) seconds),
JedisConverters.longToBoolean()));
return null;
}
if (isQueueing()) {
transaction(connection.newJedisResult(connection.getRequiredTransaction().expire(key, (int) seconds),
JedisConverters.longToBoolean()));
return null;
}
return JedisConverters.toBoolean(connection.getJedis().expire(key, (int) seconds));
} catch (Exception ex) {
throw connection.convertJedisAccessException(ex);
}
}
代码示例来源:origin: mindwind/craft-atom
private void expire0(String key, int seconds) {
t.expire(key, seconds);
}
代码示例来源:origin: io.leopard/leopard-redis
@Override
public Object execute(Jedis jedis) {
Transaction transaction = jedis.multi();
for (int i = 0; i < keyList.size(); i++) {
transaction.append(keyList.get(i), valueList.get(i));
transaction.expire(keyList.get(i), seconds);
}
transaction.exec();
return true;
}
});
代码示例来源:origin: apache/apex-malhar
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void put(Object key, Object value)
{
if (isInTransaction()) {
if (value instanceof Map) {
transaction.hmset(key.toString(), (Map)value);
} else {
transaction.set(key.toString(), value.toString());
}
if (keyExpiryTime != -1) {
transaction.expire(key.toString(), keyExpiryTime);
}
} else {
if (value instanceof Map) {
jedis.hmset(key.toString(), (Map)value);
} else {
jedis.set(key.toString(), value.toString());
}
if (keyExpiryTime != -1) {
jedis.expire(key.toString(), keyExpiryTime);
}
}
}
代码示例来源:origin: org.apache.apex/malhar-contrib
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void put(Object key, Object value)
{
if (isInTransaction()) {
if (value instanceof Map) {
transaction.hmset(key.toString(), (Map) value);
}
else {
transaction.set(key.toString(), value.toString());
}
if (keyExpiryTime != -1) {
transaction.expire(key.toString(), keyExpiryTime);
}
}
else {
if (value instanceof Map) {
jedis.hmset(key.toString(), (Map) value);
}
else {
jedis.set(key.toString(), value.toString());
}
if (keyExpiryTime != -1) {
jedis.expire(key.toString(), keyExpiryTime);
}
}
}
代码示例来源:origin: io.leopard/leopard-redis
@Override
public Object execute(Jedis jedis) {
Transaction transaction = jedis.multi();
transaction.append(key, value);
transaction.expire(key, seconds);
transaction.exec();
return true;
}
});
代码示例来源:origin: apache/apex-malhar
/**
* Calls hincrbyfloat on the redis store.
*
* @param key
* @param field
* @param doubleValue
*/
public void hincrByFloat(String key, String field, double doubleValue)
{
if (isInTransaction()) {
transaction.hincrByFloat(key, field, doubleValue);
if (keyExpiryTime != -1) {
transaction.expire(key, keyExpiryTime);
}
} else {
jedis.hincrByFloat(key, field, doubleValue);
if (keyExpiryTime != -1) {
jedis.expire(key, keyExpiryTime);
}
}
}
代码示例来源:origin: apache/apex-malhar
/**
* Calls incrbyfloat on the redis store.
*
* @param key
* @param doubleValue
*/
public void incrByFloat(String key, double doubleValue)
{
if (isInTransaction()) {
transaction.incrByFloat(key, doubleValue);
if (keyExpiryTime != -1) {
transaction.expire(key, keyExpiryTime);
}
} else {
jedis.incrByFloat(key, doubleValue);
if (keyExpiryTime != -1) {
jedis.expire(key, keyExpiryTime);
}
}
}
代码示例来源:origin: org.apache.apex/malhar-contrib
/**
* Calls incrbyfloat on the redis store.
*
* @param key
* @param doubleValue
*/
public void incrByFloat(String key, double doubleValue)
{
if (isInTransaction()) {
transaction.incrByFloat(key, doubleValue);
if (keyExpiryTime != -1) {
transaction.expire(key, keyExpiryTime);
}
}
else {
jedis.incrByFloat(key, doubleValue);
if (keyExpiryTime != -1) {
jedis.expire(key, keyExpiryTime);
}
}
}
代码示例来源:origin: org.apache.apex/malhar-contrib
/**
* Calls hincrbyfloat on the redis store.
*
* @param key
* @param field
* @param doubleValue
*/
public void hincrByFloat(String key, String field, double doubleValue)
{
if (isInTransaction()) {
transaction.hincrByFloat(key, field, doubleValue);
if (keyExpiryTime != -1) {
transaction.expire(key, keyExpiryTime);
}
}
else {
jedis.hincrByFloat(key, field, doubleValue);
if (keyExpiryTime != -1) {
jedis.expire(key, keyExpiryTime);
}
}
}
代码示例来源:origin: com.github.sogyf/goja-mvt
@Override
public void action(Transaction trans) {
Integer nextMessageId = getNextMessageId();
String msgKey = topic.cat("message").cat(nextMessageId).key();
if (message instanceof String) {
trans.set(msgKey, (String) message);
} else {
trans.set(msgKey.getBytes(), SerializableKit.toByteArray(message));
}
Logger.info("produce a message,key[" + msgKey + "],message[" + message + "]");
trans.set(topic.key(), nextMessageId.toString());
if (seconds > 0) {
trans.expire(msgKey, seconds);
}
}
});
代码示例来源:origin: Comcast/cmb
tr.expire(redisKey, exp); //expire after exp seconds
代码示例来源:origin: xetorthio/rmq
/**
*
* @param message
* menssage
* @param seconds
* expiry time
*/
public void publish(String message, int seconds) {
List<Object> exec = null;
Integer lastMessageId = null;
do {
topic.watch();
lastMessageId = getNextMessageId();
Transaction trans = jedis.multi();
String msgKey = topic.cat("message").cat(lastMessageId).key();
trans.set(msgKey, message);
trans.set(topic.key(), lastMessageId.toString());
if (seconds > 0)
trans.expire(msgKey, seconds);
exec = trans.exec();
} while (exec == null);
}
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Boolean expire(byte[] key, long seconds) {
Assert.notNull(key, "Key must not be null!");
if (seconds > Integer.MAX_VALUE) {
return pExpire(key, TimeUnit.SECONDS.toMillis(seconds));
}
try {
if (isPipelined()) {
pipeline(connection.newJedisResult(connection.getRequiredPipeline().expire(key, (int) seconds),
JedisConverters.longToBoolean()));
return null;
}
if (isQueueing()) {
transaction(connection.newJedisResult(connection.getRequiredTransaction().expire(key, (int) seconds),
JedisConverters.longToBoolean()));
return null;
}
return JedisConverters.toBoolean(connection.getJedis().expire(key, (int) seconds));
} catch (Exception ex) {
throw connection.convertJedisAccessException(ex);
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public Boolean expire(byte[] key, long seconds) {
Assert.notNull(key, "Key must not be null!");
if (seconds > Integer.MAX_VALUE) {
return pExpire(key, TimeUnit.SECONDS.toMillis(seconds));
}
try {
if (isPipelined()) {
pipeline(connection.newJedisResult(connection.getRequiredPipeline().expire(key, (int) seconds),
JedisConverters.longToBoolean()));
return null;
}
if (isQueueing()) {
transaction(connection.newJedisResult(connection.getRequiredTransaction().expire(key, (int) seconds),
JedisConverters.longToBoolean()));
return null;
}
return JedisConverters.toBoolean(connection.getJedis().expire(key, (int) seconds));
} catch (Exception ex) {
throw connection.convertJedisAccessException(ex);
}
}
内容来源于网络,如有侵权,请联系作者删除!