/// <summary> /// Internal private hashing method. /// /// This is the new hashing algorithm from other clients. /// Found to be fast and have very good distribution. /// /// UPDATE: this is dog slow under java. Maybe under .NET? /// </summary> /// <param name="key">string to hash</param> /// <returns>hashcode for this string using memcached's hashing algorithm</returns> private static int NewHashingAlgorithm(string key) { CRCTool checksum = new CRCTool(); checksum.Init(CRCTool.CRCCode.CRC32); int crc = (int)checksum.crctablefast(Encoding.UTF8.GetBytes(key)); return((crc >> 16) & 0x7fff); }
/// <summary> /// Internal private hashing method. /// /// This is the new hashing algorithm from other clients. /// Found to be fast and have very good distribution. /// /// UPDATE: this is dog slow under java. Maybe under .NET? /// </summary> /// <param name="key">string to hash</param> /// <returns>hashcode for this string using memcached's hashing algorithm</returns> private static int NewHashingAlgorithm(string key) { CRCTool checksum = new CRCTool(); checksum.Init(CRCTool.CRCCode.CRC32); int crc = (int)checksum.crctablefast(Encoding.UTF8.GetBytes(key)); return (crc >> 16) & 0x7fff; }