1 //------------------------------------------------------------------------------
2 // <copyright file="QueryCacheKey.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
7 // @backupOwner Microsoft
8 //------------------------------------------------------------------------------
10 namespace System.Data.Common.QueryCache
13 using System.Collections.Generic;
18 /// represents an abstract cache key
20 internal abstract class QueryCacheKey
23 protected const int EstimatedParameterStringSize = 20;
30 private uint _hitCount;
35 private int _agingIndex;
38 /// default string comparison kind - Ordinal
40 protected static StringComparison _stringComparison = StringComparison.Ordinal;
44 protected QueryCacheKey()
50 #region Abstract Methods
52 /// Determines whether two instances of QueryCacheContext are equal.
53 /// Equality is value based.
55 /// <param name="obj"></param>
56 /// <returns></returns>
57 public abstract override bool Equals( object obj );
60 /// Returns QueryCacheContext instance HashCode
62 /// <returns></returns>
63 public abstract override int GetHashCode();
68 /// Cache entry hit count
70 internal uint HitCount
84 /// Gets/Sets Aging index for cache entry
86 internal int AgingIndex
100 /// Updates hit count
102 internal void UpdateHit()
104 if (uint.MaxValue != _hitCount)
106 unchecked { _hitCount++; }
111 /// default string comparer
113 /// <param name="s"></param>
114 /// <param name="t"></param>
115 /// <returns></returns>
116 protected virtual bool Equals( string s, string t )
118 return String.Equals(s, t, _stringComparison);