本文整理了Java中org.springframework.data.redis.connection.RedisConnection.expire
方法的一些代码示例,展示了RedisConnection.expire
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisConnection.expire
方法的具体详情如下:
包路径:org.springframework.data.redis.connection.RedisConnection
类名称:RedisConnection
方法名:expire
暂无
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Boolean expire(byte[] key, long seconds) {
return convertAndReturn(delegate.expire(key, seconds), identityConverter);
}
代码示例来源:origin: spring-projects/spring-security-oauth
int seconds = Long.valueOf((expiration.getTime() - System.currentTimeMillis()) / 1000L)
.intValue();
conn.expire(refreshKey, seconds);
conn.expire(refreshAuthKey, seconds);
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public Boolean expire(K key, final long timeout, final TimeUnit unit) {
byte[] rawKey = rawKey(key);
long rawTimeout = TimeoutUtils.toMillis(timeout, unit);
return execute(connection -> {
try {
return connection.pExpire(rawKey, rawTimeout);
} catch (Exception e) {
// Driver may not support pExpire or we may be running on Redis 2.4
return connection.expire(rawKey, TimeoutUtils.toSeconds(timeout, unit));
}
}, true);
}
代码示例来源:origin: apache/nifi
@Override
public <K, V> boolean putIfAbsent(final K key, final V value, final Serializer<K> keySerializer, final Serializer<V> valueSerializer) throws IOException {
return withConnection(redisConnection -> {
final Tuple<byte[],byte[]> kv = serialize(key, value, keySerializer, valueSerializer);
boolean set = redisConnection.setNX(kv.getKey(), kv.getValue());
if (ttl != -1L && set) {
redisConnection.expire(kv.getKey(), ttl);
}
return set;
});
}
代码示例来源:origin: spring-projects/spring-security-oauth
if (token.getExpiration() != null) {
int seconds = token.getExpiresIn();
conn.expire(accessKey, seconds);
conn.expire(authKey, seconds);
conn.expire(authToAccessKey, seconds);
conn.expire(clientId, seconds);
conn.expire(approvalKey, seconds);
int seconds = Long.valueOf((expiration.getTime() - System.currentTimeMillis()) / 1000L)
.intValue();
conn.expire(refreshToAccessKey, seconds);
conn.expire(accessToRefreshKey, seconds);
代码示例来源:origin: apache/nifi
redisConnection.expire(kv.getKey(), ttl);
代码示例来源:origin: spring-projects/spring-data-redis
connection.expire(redisKey, rdo.getTimeToLive());
connection.expire(phantomKey, rdo.getTimeToLive() + 300);
代码示例来源:origin: spring-projects/spring-data-redis
connection.expire(objectKey, rdo.getTimeToLive());
connection.del(phantomKey);
connection.hMSet(phantomKey, rdo.getBucket().rawMap());
connection.expire(phantomKey, rdo.getTimeToLive() + 300);
代码示例来源:origin: zhangxd1989/springboot-dubbox
/**
* 添加到带有 过期时间的 缓存
*
* @param key redis主键
* @param value 值
* @param time 过期时间
*/
public void setExpire(final byte[] key, final byte[] value, final long time) {
redisTemplate.execute((RedisCallback<Long>) connection -> {
connection.set(key, value);
connection.expire(key, time);
LOGGER.info("[redisTemplate redis]放入 缓存 url:{} ========缓存时间为{}秒", key, time);
return 1L;
});
}
代码示例来源:origin: zhangxd1989/springboot-dubbox
/**
* 添加到带有 过期时间的 缓存
*
* @param key redis主键
* @param value 值
* @param time 过期时间
*/
public void setExpire(final String key, final String value, final long time) {
redisTemplate.execute((RedisCallback<Long>) connection -> {
RedisSerializer<String> serializer = getRedisSerializer();
byte[] keys = serializer.serialize(key);
byte[] values = serializer.serialize(value);
connection.set(keys, values);
connection.expire(keys, time);
LOGGER.info("[redisTemplate redis]放入 缓存 url:{} ========缓存时间为{}秒", key, time);
return 1L;
});
}
代码示例来源:origin: zhangxd1989/springboot-dubbox
/**
* 一次性添加数组到 过期时间的 缓存,不用多次连接,节省开销
*
* @param keys redis主键数组
* @param values 值数组
* @param time 过期时间
*/
public void setExpire(final String[] keys, final String[] values, final long time) {
redisTemplate.execute((RedisCallback<Long>) connection -> {
RedisSerializer<String> serializer = getRedisSerializer();
for (int i = 0; i < keys.length; i++) {
byte[] bKeys = serializer.serialize(keys[i]);
byte[] bValues = serializer.serialize(values[i]);
connection.set(bKeys, bValues);
connection.expire(bKeys, time);
LOGGER.info("[redisTemplate redis]放入 缓存 url:{} ========缓存时间为:{}秒", keys[i], time);
}
return 1L;
});
}
代码示例来源:origin: souyunku/SpringBootExamples
/**
* 设置超时时间
*
* @param key
* @param seconds
*/
public static void expire(String key, int seconds) {
cacheUtils.redisTemplate
.execute((RedisCallback<Boolean>) connection -> connection.expire(key.getBytes(), seconds));
}
代码示例来源:origin: vangao1989/cloudE
public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
Boolean isSuccess = connection.hSet(key.getBytes(), field.getBytes(), value.getBytes());
if (liveTime > 0) {
connection.expire(key.getBytes(), liveTime);
}
return isSuccess;
}
});
代码示例来源:origin: vangao1989/cloudE
public Long doInRedis(RedisConnection connection) throws DataAccessException {
connection.set(key, value);
if (liveTime > 0) {
connection.expire(key, liveTime);
}
return 1L;
}
});
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Boolean expire(byte[] key, long seconds) {
return convertAndReturn(delegate.expire(key, seconds), identityConverter);
}
代码示例来源:origin: caojx-git/learn
public Long doInRedis(RedisConnection connection) throws DataAccessException {
byte[] keyb = keyStr.getBytes();
byte[] valueb = toByteArray(valueStr);
connection.set(keyb, valueb);
if (liveTime > 0) {
connection.expire(keyb, liveTime);
}
return 1L;
}
}, true);
代码示例来源:origin: dhis2/dhis2-core
@Override
public void renewLeader()
{
if ( isLeader() )
{
log.debug( "Renewing leader with nodeId:" + this.nodeId );
redisTemplate.getConnectionFactory().getConnection().expire( key.getBytes(), timeToLiveSeconds );
}
}
代码示例来源:origin: root-wyj/springboot_im
@Override
public Boolean doInRedis(RedisConnection connection) throws DataAccessException {
RedisSerializer<String> serializer = redisTemplate.getStringSerializer();
boolean result = connection.expire(serializer.serialize(key), expire);
connection.close();
return result;
}
});
代码示例来源:origin: org.hsweb/hsweb-web-concurrent-cache
@Override
public void put(Object key, Object value) {
super.put(key, value);
redisOperations.execute((RedisCallback) connection -> {
connection.multi();
connection.incr(putTimeKey);
connection.sAdd(keySetKey, ((String) key).getBytes());
if (expiration != 0) connection.expire(keySetKey, expiration);
connection.exec();
return null;
});
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public Boolean expire(K key, final long timeout, final TimeUnit unit) {
byte[] rawKey = rawKey(key);
long rawTimeout = TimeoutUtils.toMillis(timeout, unit);
return execute(connection -> {
try {
return connection.pExpire(rawKey, rawTimeout);
} catch (Exception e) {
// Driver may not support pExpire or we may be running on Redis 2.4
return connection.expire(rawKey, TimeoutUtils.toSeconds(timeout, unit));
}
}, true);
}
内容来源于网络,如有侵权,请联系作者删除!