当前位置: 首页>>代码示例>>Java>>正文


Java ShardedJedisPipeline.expire方法代码示例

本文整理汇总了Java中redis.clients.jedis.ShardedJedisPipeline.expire方法的典型用法代码示例。如果您正苦于以下问题:Java ShardedJedisPipeline.expire方法的具体用法?Java ShardedJedisPipeline.expire怎么用?Java ShardedJedisPipeline.expire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.clients.jedis.ShardedJedisPipeline的用法示例。


在下文中一共展示了ShardedJedisPipeline.expire方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hsetByte

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
/**
 * 在hash中存入单个键值对
 * 
 * @param key
 * @param field
 * @param value
 * @param expireTime
 */
public void hsetByte(String key, String field, Object value, int expireTime) {
    ShardedJedis shardedJedis = shardedJedisPool.getResource();
    if (shardedJedis == null) {
        return;
    }
    try {
        ShardedJedisPipeline pipelined = shardedJedis.pipelined();
        pipelined.hset(serializer.serialize(key), serializer.serialize(field),
                serializer.serialize(value));
        pipelined.expire(serializer.serialize(key), expireTime);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    } finally {
        shardedJedis.close();
    }
}
 
开发者ID:hailin0,项目名称:pagecache-parent,代码行数:25,代码来源:JedisManager.java

示例2: setByNX

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
@Override
public boolean setByNX(final String key, final String value, final int timeout) {
    Assert.hasText(key);
    Assert.hasText(value);
    ShardedJedis jedis = null;
    try {
        jedis = POOL.getJedis(config.getRedisType());
        final ShardedJedisPipeline pipeline = jedis.pipelined();
        final Response<Long> set = pipeline.setnx(key, value);
        final Response<Long> expire = pipeline.expire(key, timeout);
        pipeline.sync();
        return isSuccess(set.get()) && isSuccess(expire.get());
    } catch (final Throwable e) {
        throw new RedisClientException(e.getMessage(), e);
    } finally {
        POOL.close(jedis);
    }
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:19,代码来源:RedisClientImpl.java

示例3: pAddSet

import redis.clients.jedis.ShardedJedisPipeline; //导入方法依赖的package包/类
public List<Object> pAddSet(String key, int seconds, String... values) {
    try (ShardedJedis shardedJedis = shardedJedisPool.getResource()) {
        ShardedJedisPipeline pipeline = shardedJedis.pipelined();
        for(String value : values) {
            pipeline.sadd(key, value);
        }
        pipeline.expire(key, seconds);
        List<Object> result = pipeline.syncAndReturnAll();
        result.remove(result.size() -1);
        return result;
    }
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:13,代码来源:RedisTemplate.java


注:本文中的redis.clients.jedis.ShardedJedisPipeline.expire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。