public enum DefaultHashAlgorithm extends Enum<DefaultHashAlgorithm> implements HashAlgorithm
Known hashing algorithms for locating a server for a key. Note that all hash algorithms return 64-bits of hash, but only the lower 32-bits are significant. This allows a positive 32-bit number to be returned for all cases.
This has been borrowed from SpyMemcached.
Enum Constant and Description |
---|
AREDIS_HASH
An improvement of String.hashCode which gives near hash codes for keys with a common prefix.
|
CRC_HASH
CRC_HASH as used by the perl API.
|
FNV1_32_HASH
32-bit FNV1.
|
FNV1_64_HASH
FNV hashes are designed to be fast while maintaining a low collision rate.
|
FNV1A_32_HASH
32-bit FNV1a.
|
FNV1A_64_HASH
Variation of FNV.
|
KETAMA_HASH
MD5-based hash algorithm used by ketama.
|
NATIVE_HASH
Native hash (String.hashCode()).
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
computeMd5(String k)
Get the md5 of the given key.
|
int |
hash(String k)
Compute the hash for the given key.
|
static DefaultHashAlgorithm |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static DefaultHashAlgorithm[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final DefaultHashAlgorithm NATIVE_HASH
public static final DefaultHashAlgorithm AREDIS_HASH
public static final DefaultHashAlgorithm CRC_HASH
public static final DefaultHashAlgorithm FNV1_64_HASH
public static final DefaultHashAlgorithm FNV1A_64_HASH
public static final DefaultHashAlgorithm FNV1_32_HASH
public static final DefaultHashAlgorithm FNV1A_32_HASH
public static final DefaultHashAlgorithm KETAMA_HASH
public static DefaultHashAlgorithm[] values()
for (DefaultHashAlgorithm c : DefaultHashAlgorithm.values()) System.out.println(c);
public static DefaultHashAlgorithm valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant
with the specified nameNullPointerException
- if the argument is nullpublic int hash(String k)
hash
in interface HashAlgorithm
public static byte[] computeMd5(String k)
Copyright © 2013- Suresh Mahalingam. All Rights Reserved.