redis / jedis

Redis Java client
MIT License
11.86k stars 3.87k forks source link

Implement byte[] support in ShardedJedisPipeline #354

Closed papirosko closed 9 years ago

papirosko commented 12 years ago

We have big traffic between clients and redis server, most because of passing keys as strings (we pass uuid). Sending byte[] through pipeline will help.

Also add some way to specify shard (choosing shard with regexp on highload is too bad). Smth like:

ShardedJedisPipeline pipelined = resource.pipelined();

String uuid1 = ...; byte[] key1 = uuid1.toByteArray(); String uuid2 = ...; byte[] key2 = uuid1.toByteArray(); Response res1 = pipelined.get( key1, calcShardIdxFor(uuid1) ); Response res2 = pipelined.get( key2, calcShardIdxFor(uuid2) ); ...

public statis int calcShardIdxFor(String shardKey) { return HashUtils.getHash(shardKey) % SHARDS_COUNT; }

samhendley commented 11 years ago

I believe the SharedJedisPipeline is already capable of doing this, in what way is not working as expected?