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

The following examples show how to use redis.clients.jedis.Jedis#setrange() . 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: RedisServiceImpl.java    From ace-cache with Apache License 2.0 5 votes vote down vote up
@Override
public Long setrange(String key, String str, int offset) {
    Jedis jedis = null;
    try {
        jedis = pool.getResource();
        return jedis.setrange(key, offset, str);
    } catch (Exception e) {

        LOGGER.error(e.getMessage());
        return 0L;
    } finally {
        returnResource(pool, jedis);
    }
}
 
Example 2
Source File: DefaultRedis.java    From craft-atom with MIT License 4 votes vote down vote up
private Long setrange0(Jedis j, String key, long offset, String value) {
	return j.setrange(key, offset, value);
}
 
Example 3
Source File: JedisUtils.java    From fw-spring-cloud with Apache License 2.0 3 votes vote down vote up
/**
 * <p>
 * 通过key 和offset 从指定的位置开始将原先value替换
 * </p>
 * <p>
 * 下标从0开始,offset表示从offset下标开始替换
 * </p>
 * <p>
 * 如果替换的字符串长度过小则会这样
 * </p>
 * <p>
 * example:
 * </p>
 * <p>
 * value : [email protected]
 * </p>
 * <p>
 * str : abc
 * </p>
 * <P>
 * 从下标7开始替换 则结果为
 * </p>
 * <p>
 * RES : bigsea.abc.cn
 * </p>
 *
 * @param key
 * @param str
 * @param offset
 *            下标位置
 * @return 返回替换后 value 的长度
 */
public Long setrange(String key, String str, int offset) {
    Jedis jedis = null;
    try {
        jedis = jedisPool.getResource();
        return jedis.setrange(key, offset, str);
    } catch (Exception e) {

        log.error(e.getMessage());
        return 0L;
    } finally {
        returnResource(jedisPool, jedis);
    }
}
 
Example 4
Source File: JedisUtil.java    From Project with Apache License 2.0 3 votes vote down vote up
/**
 * 从指定位置开始插入数据,插入的数据会覆盖指定位置以后的数据<br/>
 * 例:String str1="123456789";<br/>
 * 对str1操作后setRange(key,4,0000),str1="123400009";
 * 
 * @param  key
 * @param         offset
 * @param  value
 * @return long value的长度
 */
public long setRange(String key, long offset, String value) {
	Jedis jedis = getJedis();
	long len = jedis.setrange(key, offset, value);
	jedis.close();
	return len;
}
 
Example 5
Source File: JedisUtil.java    From BigData with GNU General Public License v3.0 3 votes vote down vote up
/**
 * 从指定位置开始插入数据,插入的数据会覆盖指定位置以后的数据<br/>
 * 例:String str1="123456789";<br/>
 * 对str1操作后setRange(key,4,0000),str1="123400009";
 * 
 * @param String
 *            key
 * @param long offset
 * @param String
 *            value
 * @return long value的长度
 * */
public long setRange(String key, long offset, String value) {
	Jedis jedis = getJedis();
	long len = jedis.setrange(key, offset, value);
	returnJedis(jedis);
	return len;
}