本文整理汇总了Java中redis.clients.jedis.ShardedJedis类的典型用法代码示例。如果您正苦于以下问题:Java ShardedJedis类的具体用法?Java ShardedJedis怎么用?Java ShardedJedis使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ShardedJedis类属于redis.clients.jedis包,在下文中一共展示了ShardedJedis类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanHSet
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
/**
* 全局扫描hset
*
* @param match field匹配模式
*/
public List<Map.Entry<String, String>> scanHSet(String domain, String match) {
try (ShardedJedis shardedJedis = shardedJedisPool.getResource()) {
int cursor = 0;
ScanParams scanParams = new ScanParams();
scanParams.match(match);
Jedis jedis = shardedJedis.getShard(domain);
ScanResult<Map.Entry<String, String>> scanResult;
List<Map.Entry<String, String>> list = new ArrayList<Map.Entry<String, String>>();
do {
scanResult = jedis.hscan(domain, String.valueOf(cursor), scanParams);
list.addAll(scanResult.getResult());
cursor = Integer.parseInt(scanResult.getStringCursor());
} while (cursor > 0);
return list;
}
}
示例2: saveFile
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
@Override
public void saveFile(String fileLengthKey, String fileDataKey, String fileName, List<byte[]> values, long fileLength) {
ShardedJedis shardedJedis = getShardedJedis();
ShardedJedisPipeline pipelined = shardedJedis.pipelined();
pipelined.hset(fileLengthKey.getBytes(), fileName.getBytes(), Longs.toByteArray(fileLength));
Long blockSize = getBlockSize(fileLength);
for (int i = 0; i < blockSize; i++) {
pipelined.hset(fileDataKey.getBytes(), getBlockName(fileName, i), compressFilter(values.get(i)));
if (i % Constants.SYNC_COUNT == 0) {
pipelined.sync();
pipelined = shardedJedis.pipelined();
}
}
pipelined.sync();
shardedJedis.close();
values.clear();
}
示例3: checkCloseable
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
@Test
public void checkCloseable() {
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
shards.add(new JedisShardInfo(redis1.getHost(), redis1.getPort()));
shards.add(new JedisShardInfo(redis2.getHost(), redis2.getPort()));
shards.get(0).setPassword("foobared");
shards.get(1).setPassword("foobared");
ShardedJedis jedisShard = new ShardedJedis(shards);
try {
jedisShard.set("shard_closeable", "true");
} finally {
jedisShard.close();
}
for (Jedis jedis : jedisShard.getAllShards()) {
assertTrue(!jedis.isConnected());
}
}
示例4: run
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public static <K> K run(String key, Executor<K> executor, Integer... expire) {
ShardedJedis jedis = getJedis();
if (jedis == null) {
return null;
}
try {
K result = executor.execute(jedis);
if (jedis.exists(key)) {
if (expire == null || expire.length == 0) {
jedis.expire(key, EXPIRE);
} else if (expire.length == 1) {
jedis.expire(key, expire[0]);
}
}
return result;
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
if (jedis != null) {
jedis.close();
}
}
return null;
}
示例5: incr
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public final Long incr(final String key) {
return jedisTemplate.run(key, new Executor<Long>() {
public Long execute(ShardedJedis jedis) {
return jedis.incr(key);
}
});
}
示例6: zrangeWithScores
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public static final Set<Tuple> zrangeWithScores(final String key, final int start, final int end) {
return JedisTemplate.run(key, new Executor<Set<Tuple>>() {
public Set<Tuple> execute(ShardedJedis jedis) {
return jedis.zrangeWithScores(key, start, end);
}
});
}
示例7: rpush
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public final Long rpush(final byte[] key, final byte[] string) {
return jedisTemplate.run(key, new Executor<Long>() {
public Long execute(ShardedJedis jedis) {
return jedis.rpush(key, string);
}
});
}
示例8: hdel
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public Long hdel(final byte[] key, final byte[] field) {
return jedisTemplate.run(key, new Executor<Long>() {
public Long execute(ShardedJedis jedis) {
return jedis.hdel(key, field);
}
});
}
示例9: sort
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public static final List<byte[]> sort(final byte[] key, final SortingParams sortingParameters) {
return JedisTemplate.run(key, new Executor<List<byte[]>>() {
public List<byte[]> execute(ShardedJedis jedis) {
return jedis.sort(key, sortingParameters);
}
});
}
示例10: hdel
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public Long hdel(final byte[] key, final byte[] field) {
return JedisTemplate.run(key, new Executor<Long>() {
public Long execute(ShardedJedis jedis) {
return jedis.hdel(key, field);
}
});
}
示例11: srandmember
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public final String srandmember(final String key) {
return jedisTemplate.run(key, new Executor<String>() {
public String execute(ShardedJedis jedis) {
return jedis.srandmember(key);
}
});
}
示例12: resetRequestRepeatCheck
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
@Override
public void resetRequestRepeatCheck(Task task, Request request) {
ShardedJedis jedis = jedisPool.getResource();
try {
jedis.srem(RedisKeys.getSetKey(task), request.key());
} finally {
jedis.close();
}
}
示例13: zcard
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public static final Long zcard(final byte[] key) {
return JedisTemplate.run(key, new Executor<Long>() {
public Long execute(ShardedJedis jedis) {
return jedis.zcard(key);
}
});
}
示例14: hmset
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public static final String hmset(final String key, final Map<String, String> hash) {
return JedisTemplate.run(key, new Executor<String>() {
public String execute(ShardedJedis jedis) {
return jedis.hmset(key, hash);
}
});
}
示例15: ttl
import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public final Long ttl(final byte[] key) {
return jedisTemplate.run(key, new Executor<Long>() {
public Long execute(ShardedJedis jedis) {
return jedis.ttl(key);
}
});
}