예제 #1
0
 /// <summary>
 /// Clears the cache.
 /// </summary>
 public virtual void Clear()
 {
     using (WriteLockScope wls = _cacheRoot.GetWriteLockScope())
     {
         _cacheRoot.Clear();
     }
 }
예제 #2
0
        /// <summary>
        /// Invoked for deleting mapping in cache becase it no longer exists in store.
        /// </summary>
        /// <param name="mapping">Storage representation of mapping.</param>
        public virtual void DeleteMapping(IStoreMapping mapping)
        {
            using (ReadLockScope rls = _cacheRoot.GetReadLockScope(false))
            {
                CacheShardMap csm = _cacheRoot.LookupById(mapping.ShardMapId);

                if (csm != null)
                {
                    using (WriteLockScope wlscsm = csm.GetWriteLockScope())
                    {
                        csm.Mapper.Remove(mapping);

                        // Update perf counters for remove mapping operation and mappings count.
                        csm.IncrementPerformanceCounter(PerformanceCounterName.MappingsRemovePerSec);
                        csm.SetPerformanceCounter(PerformanceCounterName.MappingsCount, csm.Mapper.GetMappingsCount());

                        Tracer.TraceVerbose(
                            TraceSourceConstants.ComponentNames.ShardMapManager,
                            "OnDeleteMapping",
                            "Cache delete mapping complete. Mapping Id: {0}",
                            mapping.Id);
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Invoked for deleting shard map in cache becase it no longer exists in store.
        /// </summary>
        /// <param name="shardMap">Storage representation of shard map.</param>
        public virtual void DeleteShardMap(IStoreShardMap shardMap)
        {
            using (WriteLockScope wls = _cacheRoot.GetWriteLockScope())
            {
                _cacheRoot.Remove(shardMap);

                Tracer.TraceVerbose(
                    TraceSourceConstants.ComponentNames.ShardMapManager,
                    "OnDeleteShardMap",
                    "Cache delete complete. ShardMap: {0}",
                    shardMap.Name);
            }
        }
예제 #4
0
        /// <summary>
        /// Invoked for deleting mapping in cache becase it no longer exists in store.
        /// </summary>
        /// <param name="mapping">Storage representation of mapping.</param>
        public virtual void DeleteMapping(IStoreMapping mapping)
        {
            using (ReadLockScope rls = _cacheRoot.GetReadLockScope(false))
            {
                CacheShardMap csm = _cacheRoot.LookupById(mapping.ShardMapId);

                if (csm != null)
                {
                    using (WriteLockScope wlscsm = csm.GetWriteLockScope())
                    {
                        csm.Mapper.Remove(mapping);
                        Tracer.TraceVerbose(
                            TraceSourceConstants.ComponentNames.ShardMapManager,
                            "OnDeleteMapping",
                            "Cache delete mapping complete. Mapping Id: {0}",
                            mapping.Id);
                    }
                }
            }
        }