Show / Hide Table of Contents

Class ComplexKeyHashingStrategy

Provides hashing strategy for keys that are not scalar uint64. This is a companion class for CacheStore which only understands uint64 as keys for efficiency purposes. One may extend this class to implement custom resolution of complex keys into uint64 hashes and provide collision handling. The base implementation uses object.GetHashCode() with chaining for collision resolution

Inheritance
System.Object
ComplexKeyHashingStrategy
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: NFX.DataAccess.Cache
Assembly: NFX.dll
Syntax
public class ComplexKeyHashingStrategy

Constructors

ComplexKeyHashingStrategy(CacheStore)

Declaration
public ComplexKeyHashingStrategy(CacheStore store)
Parameters
Type Name Description
CacheStore store

Fields

MAX_CACHE_CHAIN_LENGTH

How many times hash will be adjusted while chaining

Declaration
public const int MAX_CACHE_CHAIN_LENGTH = 5
Field Value
Type Description
System.Int32

Store

References cachestore that this strategy works with

Declaration
public readonly CacheStore Store
Field Value
Type Description
CacheStore

Methods

ComplexKeyToCacheKey(Object)

Override to convert complex object to uint64 key. The default implementation returns DefaultComplexKeyToCacheKey(key)

Declaration
public virtual ulong ComplexKeyToCacheKey(object key)
Parameters
Type Name Description
System.Object key
Returns
Type Description
System.UInt64

DefaultComplexKeyToCacheKey(Object)

Default implementation that converts complex object to uint64 key. The default implementation returns the hashcode of the object unless the key is string in which case it calls DefaultStringKeyToCacheKey() or IULongHashProvider(GDID and parcels). The function is not deterministic due to the use of .GetHashCode() that may change between release for some objects (depends on object implementation), so the returned value should not be persisted

Declaration
public static ulong DefaultComplexKeyToCacheKey(object key)
Parameters
Type Name Description
System.Object key
Returns
Type Description
System.UInt64

DefaultStringKeyToCacheKey(String)

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

Declaration
public static ulong DefaultStringKeyToCacheKey(string key)
Parameters
Type Name Description
System.String key
Returns
Type Description
System.UInt64

Get(String, Object, Int32)

Override to get a value keyed on a non-uint64 scalar from cache. Returns null when item does not exist

Declaration
public virtual object Get(string tableName, object key, int ageSec = 0)
Parameters
Type Name Description
System.String tableName
System.Object key
System.Int32 ageSec
Returns
Type Description
System.Object

Put(String, Object, Object, Int32, Int32, Nullable<DateTime>)

Override to put a value keyed on a non-uint64 scalar into cache. Returns table.Put() result

Declaration
public virtual bool Put(string tableName, object key, object value, int maxAgeSec = 0, int priority = 0, DateTime? absoluteExpirationUTC = default (DateTime? ))
Parameters
Type Name Description
System.String tableName
System.Object key
System.Object value
System.Int32 maxAgeSec
System.Int32 priority
System.Nullable<System.DateTime> absoluteExpirationUTC
Returns
Type Description
System.Boolean

Remove(String, Object)

Override to remove an item keyed on a non-uint64 scalar from cache. Returns true if remove found and removed item from table

Declaration
public virtual bool Remove(string tableName, object key)
Parameters
Type Name Description
System.String tableName
System.Object key
Returns
Type Description
System.Boolean

Extension Methods

MiscUtils.NonNull<T>(T, Func<Exception>, String)
ObjectValueConversion.AsString(Object, String, ConvertErrorHandling)
ObjectValueConversion.AsNonNullOrEmptyString(Object)
ObjectValueConversion.AsLaconicConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsJSONConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsXMLConfig(Object, ConfigSectionNode, ConvertErrorHandling)
ObjectValueConversion.AsChar(Object, Char, ConvertErrorHandling)
ObjectValueConversion.AsNullableChar(Object, Nullable<Char>, ConvertErrorHandling)
ObjectValueConversion.AsByte(Object, Byte, ConvertErrorHandling)
ObjectValueConversion.AsNullableByte(Object, Nullable<Byte>, ConvertErrorHandling)
ObjectValueConversion.AsSByte(Object, SByte, ConvertErrorHandling)
ObjectValueConversion.AsNullableSByte(Object, Nullable<SByte>, ConvertErrorHandling)
ObjectValueConversion.AsShort(Object, Int16, ConvertErrorHandling)
ObjectValueConversion.AsNullableShort(Object, Nullable<Int16>, ConvertErrorHandling)
ObjectValueConversion.AsUShort(Object, UInt16, ConvertErrorHandling)
ObjectValueConversion.AsNullableUShort(Object, Nullable<UInt16>, ConvertErrorHandling)
ObjectValueConversion.AsInt(Object, Int32, ConvertErrorHandling)
ObjectValueConversion.AsNullableInt(Object, Nullable<Int32>, ConvertErrorHandling)
ObjectValueConversion.AsUInt(Object, UInt32, ConvertErrorHandling)
ObjectValueConversion.AsNullableUInt(Object, Nullable<UInt32>, ConvertErrorHandling)
ObjectValueConversion.AsLong(Object, Int64, ConvertErrorHandling)
ObjectValueConversion.AsNullableLong(Object, Nullable<Int64>, ConvertErrorHandling)
ObjectValueConversion.AsULong(Object, UInt64, ConvertErrorHandling)
ObjectValueConversion.AsNullableULong(Object, Nullable<UInt64>, ConvertErrorHandling)
ObjectValueConversion.AsDouble(Object, Double, ConvertErrorHandling)
ObjectValueConversion.AsNullableDouble(Object, Nullable<Double>, ConvertErrorHandling)
ObjectValueConversion.AsFloat(Object, Single, ConvertErrorHandling)
ObjectValueConversion.AsNullableFloat(Object, Nullable<Single>, ConvertErrorHandling)
ObjectValueConversion.AsDecimal(Object, Decimal, ConvertErrorHandling)
ObjectValueConversion.AsNullableDecimal(Object, Nullable<Decimal>, ConvertErrorHandling)
ObjectValueConversion.AsBool(Object, Boolean, ConvertErrorHandling)
ObjectValueConversion.AsNullableBool(Object, Nullable<Boolean>, ConvertErrorHandling)
ObjectValueConversion.AsGUID(Object, Guid, ConvertErrorHandling)
ObjectValueConversion.AsNullableGUID(Object, Nullable<Guid>, ConvertErrorHandling)
ObjectValueConversion.AsDateTime(Object)
ObjectValueConversion.AsDateTime(Object, DateTime, ConvertErrorHandling)
ObjectValueConversion.AsNullableDateTime(Object, Nullable<DateTime>, ConvertErrorHandling)
ObjectValueConversion.AsGDID(Object)
ObjectValueConversion.AsGDID(Object, GDID, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDID(Object, Nullable<GDID>, ConvertErrorHandling)
ObjectValueConversion.AsGDIDSymbol(Object)
ObjectValueConversion.AsGDIDSymbol(Object, GDIDSymbol, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDIDSymbol(Object, Nullable<GDIDSymbol>, ConvertErrorHandling)
ObjectValueConversion.AsTimeSpan(Object)
ObjectValueConversion.AsTimeSpan(Object, TimeSpan, ConvertErrorHandling)
ObjectValueConversion.AsNullableTimeSpan(Object, Nullable<TimeSpan>, ConvertErrorHandling)
ObjectValueConversion.AsEnum<TEnum>(Object, TEnum, ConvertErrorHandling)
ObjectValueConversion.AsNullableEnum<TEnum>(Object, Nullable<TEnum>, ConvertErrorHandling)
ObjectValueConversion.AsUri(Object, Uri, ConvertErrorHandling)
JSONExtensions.ToJSON(Object, JSONWritingOptions)
JSONExtensions.ToJSON(Object, TextWriter, JSONWritingOptions)
JSONExtensions.ToJSON(Object, Stream, JSONWritingOptions, Encoding)
ErlObject.ToErlObject(Object)
ErlObject.ToErlObject(Object, ErlTypeOrder, Boolean)
Back to top Copyright © 2006-2018 Agnicore Inc
Generated by DocFX