/// <summary> /// Invoked for refreshing mapping in cache from store. /// </summary> /// <param name="mapping">Storage representation of mapping.</param> /// <param name="policy">Policy to use for preexisting cache entries during update.</param> public virtual void AddOrUpdateMapping(IStoreMapping mapping, CacheStoreMappingUpdatePolicy policy) { using (ReadLockScope rls = _cacheRoot.GetReadLockScope(false)) { CacheShardMap csm = _cacheRoot.LookupById(mapping.ShardMapId); if (csm != null) { using (WriteLockScope wlscsm = csm.GetWriteLockScope()) { csm.Mapper.AddOrUpdate(mapping, policy); // Update perf counters for add or update operation and mappings count. csm.IncrementPerformanceCounter(PerformanceCounterName.MappingsAddOrUpdatePerSec); csm.SetPerformanceCounter(PerformanceCounterName.MappingsCount, csm.Mapper.GetMappingsCount()); Tracer.TraceVerbose( TraceSourceConstants.ComponentNames.ShardMapManager, "OnAddOrUpdateMapping", "Cache Add/Update mapping complete. Mapping Id: {0}", mapping.Id); } } } }
/// <summary> /// Invoked for refreshing mapping in cache from store. /// </summary> /// <param name="mapping">Storage representation of mapping.</param> /// <param name="policy">Policy to use for preexisting cache entries during update.</param> public virtual void AddOrUpdateMapping(IStoreMapping mapping, CacheStoreMappingUpdatePolicy policy) { using (ReadLockScope rls = _cacheRoot.GetReadLockScope(false)) { CacheShardMap csm = _cacheRoot.LookupById(mapping.ShardMapId); if (csm != null) { using (WriteLockScope wlscsm = csm.GetWriteLockScope()) { csm.Mapper.AddOrUpdate(mapping, policy); Tracer.TraceVerbose( TraceSourceConstants.ComponentNames.ShardMapManager, "OnAddOrUpdateMapping", "Cache Add/Update mapping complete. Mapping Id: {0}", mapping.Id); } } } }