コード例 #1
0
        /// <summary>
        /// Looks up a given key in given shard map.
        /// </summary>
        /// <param name="shardMap">Storage representation of shard map.</param>
        /// <param name="key">Key value.</param>
        /// <returns>Mapping corresponding to <paramref name="key"/> or null.</returns>
        public virtual ICacheStoreMapping LookupMappingByKey(IStoreShardMap shardMap, ShardKey key)
        {
            ICacheStoreMapping sm = null;

            using (ReadLockScope rls = _cacheRoot.GetReadLockScope(false))
            {
                CacheShardMap csm = _cacheRoot.LookupById(shardMap.Id);

                if (csm != null)
                {
                    using (ReadLockScope rlsShardMap = csm.GetReadLockScope(false))
                    {
                        IStoreMapping smDummy;
                        sm = csm.Mapper.LookupByKey(key, out smDummy);

                        /*
                         *          // perf counter can not be updated in csm.Mapper.LookupByKey() as this function is also called from csm.Mapper.AddOrUpdate()
                         *          // so updating perf counter value here instead.
                         *          csm.IncrementPerformanceCounter(sm == null ? PerformanceCounterName.MappingsLookupFailedPerSec : PerformanceCounterName.MappingsLookupSucceededPerSec);
                         */
                    }
                }
            }

            return(sm);
        }