/** * 通过key 和offset 从指定的位置开始将原先value替换 * * <p>下标从0开始,offset表示从offset下标开始替换 * * <p>如果替换的字符串长度过小则会这样 * * <p>example: * * <p>value : [email protected] * * <p>str : abc * * <p>从下标7开始替换 则结果为 * * <p>RES : bigsea.abc.cn * * @param key * @param str * @param offset 下标位置 * @return 返回替换后 value 的长度 */ public Long setrange(String key, String str, int offset) { ShardedJedis jedis = null; try { jedis = pool.getResource(); return jedis.setrange(key, offset, str); } catch (Exception e) { pool.returnBrokenResource(jedis); e.printStackTrace(); return 0L; } finally { returnResource(pool, jedis); } }