Java Code Examples for redis.clients.jedis.Jedis#ltrim()

The following examples show how to use redis.clients.jedis.Jedis#ltrim() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JedisUtils.java    From fw-spring-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * 通过key保留list中从strat下标开始到end下标结束的value值
 * </p>
 *
 * @param key
 * @param start
 * @param end
 * @return 成功返回OK
 */
public String ltrim(String key, long start, long end) {
    Jedis jedis = null;
    String res = null;
    try {
        jedis = jedisPool.getResource();
        res = jedis.ltrim(key, start, end);
    } catch (Exception e) {

        log.error(e.getMessage());
    } finally {
        returnResource(jedisPool, jedis);
    }
    return res;
}
 
Example 2
Source File: JedisUtil.java    From scaffold-cloud with MIT License 5 votes vote down vote up
/**
 * 对一个列表进行修剪(trim),就是说,让列表只保留指定区间内的元素,不在指定区间之内的元素都将被删除。
 *
 * @param key
 * @param start
 * @param end
 */
public static void ltrim(String key, long start, long end) {
    Jedis jedis = null;
    try {
        jedis = getResource();
        jedis.ltrim(key, start, end);
    } catch (Exception e) {
        logger.warn("trim{}", key, e);
    } finally {
        close(jedis);
    }
}
 
Example 3
Source File: RedisClient.java    From Mykit with Apache License 2.0 5 votes vote down vote up
public void ltrim(String key, int start, int stop) {
	Jedis client = jedisPool.getResource();
	try {
		client.ltrim(key, start, stop);
	} finally {
		// 向连接池“归还”资源
		jedisPool.returnResourceObject(client);
	}
}
 
Example 4
Source File: RedisServiceImpl.java    From ace-cache with Apache License 2.0 5 votes vote down vote up
@Override
public String ltrim(String key, long start, long end) {
    Jedis jedis = null;
    String res = null;
    try {
        jedis = pool.getResource();
        res = jedis.ltrim(key, start, end);
    } catch (Exception e) {

        LOGGER.error(e.getMessage());
    } finally {
        returnResource(pool, jedis);
    }
    return res;
}
 
Example 5
Source File: RedisTaskResultStore.java    From helix with Apache License 2.0 5 votes vote down vote up
@Override
public void ltrim(String key, long start, long end) throws Exception {
  Jedis jedis = _jedisPool.getResource();
  try {
    jedis.ltrim(key, start, end);
  } finally {
    _jedisPool.returnResource(jedis);
  }
}
 
Example 6
Source File: DefaultRedis.java    From craft-atom with MIT License 4 votes vote down vote up
private String ltrim0(Jedis j, String key, long start, long stop) {
	return j.ltrim(key, start, stop);
}
 
Example 7
Source File: JedisUtil.java    From Project with Apache License 2.0 3 votes vote down vote up
/**
 * 算是删除吧,只保留start与end之间的记录
 * 
 * @param  key
 * @param start 记录的开始位置(0表示第一条记录)
 * @param  end 记录的结束位置(如果为-1则表示最后一个,-2,-3以此类推)
 * @return 执行状态码
 */
public String ltrim(byte[] key, int start, int end) {
	Jedis jedis = getJedis();
	String str = jedis.ltrim(key, start, end);
	jedis.close();
	return str;
}
 
Example 8
Source File: JedisUtil.java    From BigData with GNU General Public License v3.0 3 votes vote down vote up
/**
 * 算是删除吧,只保留start与end之间的记录
 * 
 * @param byte[] key
 * @param int start 记录的开始位置(0表示第一条记录)
 * @param int end 记录的结束位置(如果为-1则表示最后一个,-2,-3以此类推)
 * @return 执行状态码
 * */
public String ltrim(byte[] key, int start, int end) {
	Jedis jedis = getJedis();
	String str = jedis.ltrim(key, start, end);
	returnJedis(jedis);
	return str;
}