Binary key & values seems to be implemented now
This commit is contained in:
@@ -3,13 +3,19 @@ package redis.clients.util;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import redis.clients.jedis.Protocol;
|
||||
|
||||
public interface Hashing {
|
||||
public static final Hashing MURMUR_HASH = new MurmurHash();
|
||||
|
||||
public static final Hashing MD5 = new Hashing() {
|
||||
private MessageDigest md5 = null; // avoid recurring construction
|
||||
|
||||
|
||||
public long hash(String key) {
|
||||
return hash(key.getBytes(Protocol.UTF8));
|
||||
}
|
||||
|
||||
public long hash(byte[] key) {
|
||||
if (md5 == null) {
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
@@ -20,7 +26,7 @@ public interface Hashing {
|
||||
}
|
||||
|
||||
md5.reset();
|
||||
md5.update(key.getBytes());
|
||||
md5.update(key);
|
||||
byte[] bKey = md5.digest();
|
||||
long res = ((long) (bKey[3] & 0xFF) << 24)
|
||||
| ((long) (bKey[2] & 0xFF) << 16)
|
||||
@@ -30,4 +36,5 @@ public interface Hashing {
|
||||
};
|
||||
|
||||
public long hash(String key);
|
||||
public long hash(byte[] key);
|
||||
}
|
||||
Reference in New Issue
Block a user