Source/NFX/DataAccess/Cache/ComplexKeyHashingStrategy.cs
/// <summary>
/// Provides default implementation for converting string keys into uint64 hash.
/// This functions provides the best selectivity for strings that are 8 chars long or less.
/// The function is NOT deterministic as it uses .GetHashCode(), so the returned value should not be persisted
/// </summary>
Provides default implementation for converting string keys into uint64 hash.
This functions provides the best selectivity for strings that are 8 chars long or less.
The function is NOT deterministic as it uses .GetHashCode(), so the returned value should not be persisted
Provides default implementation for converting string keys into uint64 hash . This functions provides the best selectivity for strings that are 8 chars long or less . The function is NOT deterministic as it uses . GetHashCode () so the returned value should not be persisted
public static ulong DefaultStringKeyToCacheKey(string key)
        {
            if (key==null) return 0;
            var sl = key.Length;
            if (sl==0) return 0;
            ulong hash1 = 0;
            for(int i=sl-1; i>sl-1-sizeof(ulong) && i>=0; i--)
            {                                                 
              if (i<sl-1) hash1 <<= 8;
              var c = key[i];
              var b1 = (c & 0xff00) >> 8;
              var b2 = c & 0xff;
              hash1 |= (byte)(b1 ^ b2);
            }
            ulong hash2 = 1566083941ul * (ulong)key.GetHashCode();
            return hash1 ^ hash2;
        }
public static ulong DefaultStringKeyToCacheKey ( string key ) { if ( key == null ) return 0 ; var sl = key . Length ; if ( sl == 0 ) return 0 ; ulong hash1 = 0 ; for ( int i = sl - 1 ; i > sl - 1 - sizeof ( ulong ) && i >= 0 ; i -- ) { if ( i < sl - 1 ) hash1 <<= 8 ; var c = key [ i ] ; var b1 = ( c & 0xff00 ) >> 8 ; var b2 = c & 0xff ; hash1 |= ( byte ) ( b1 ^ b2 ) ; } ulong hash2 = 1566083941ul * ( ulong ) key . GetHashCode ( ) ; return hash1 ^ hash2 ; }
Provides default implementation for converting string keys into uint64 hash.
Provides default implementation for converting string keys into uint64 hash .
//take 8 chars from end (string suffix), for most string the //string tail is the most changing part (i.e. 'Alex Kozloff'/'Alex Richardson'/'System.A'/'System.B'
key
string