public void Reset() { removedValue = "Known bad value"; callbackHappened = false; callbackReason = CacheItemRemovedReason.Unknown; removedKey = null; instrumentationProvider = new NullCachingInstrumentationProvider(); }
public RefreshActionData(ICacheItemRefreshAction refreshAction, string keyToRefresh, object removedData, CacheItemRemovedReason removalReason, ICachingInstrumentationProvider instrumentationProvider) { this.refreshAction = refreshAction; this.keyToRefresh = keyToRefresh; this.removalReason = removalReason; this.removedData = removedData; this.instrumentationProvider = instrumentationProvider; }
public void TestInitialize() { scavengedKeys = ""; inMemoryCache = new Hashtable(); inMemoryCacheRequests = 0; inMemoryCacheRequestSemaphore = null; instrumentationProvider = new NullCachingInstrumentationProvider(); }
public void Reset() { removedValue = "Known bad value"; callbackHappened = false; callbackReason = CacheItemRemovedReason.Unknown; removedKey = null; instrumentationProvider = new NullCachingInstrumentationProvider(); }
public void TestInitialize() { scavengedKeys = ""; inMemoryCache = new Hashtable(); inMemoryCacheRequests = 0; inMemoryCacheRequestSemaphore = null; instrumentationProvider = new NullCachingInstrumentationProvider(); }
public RefreshActionData(ICacheItemRefreshAction refreshAction, string keyToRefresh, object removedData, CacheItemRemovedReason removalReason, ICachingInstrumentationProvider instrumentationProvider) { this.refreshAction = refreshAction; this.keyToRefresh = keyToRefresh; this.removalReason = removalReason; this.removedData = removedData; this.instrumentationProvider = instrumentationProvider; }
public void TestInitialize() { inMemoryCache = new Hashtable(); instrumentationProvider = new NullCachingInstrumentationProvider(); expirer = new ExpirationTask(this, instrumentationProvider); expiredItemKeys = ""; callbackCount = 0; callbackReason = CacheItemRemovedReason.Unknown; }
public void TestInitialize() { inMemoryCache = new Hashtable(); instrumentationProvider = new NullCachingInstrumentationProvider(); expirer = new ExpirationTask(this, instrumentationProvider); expiredItemKeys = ""; callbackCount = 0; callbackReason = CacheItemRemovedReason.Unknown; }
/// <summary> /// Initialize a new instance of the <see cref="ScavengerTask"/> with a <see cref="CacheManager"/> name, the <see cref="CacheCapacityScavengingPolicy"/> and the <see cref="ICacheOperations"/>. /// </summary> /// <param name="numberToRemoveWhenScavenging">The number of items that should be removed from the cache when scavenging.</param> /// <param name="maximumElementsInCacheBeforeScavenging"></param> /// <param name="cacheOperations">The <see cref="ICacheOperations"/> to perform.</param> /// <param name="instrumentationProvider">An instrumentation provider.</param> public ScavengerTask(int numberToRemoveWhenScavenging, int maximumElementsInCacheBeforeScavenging, ICacheOperations cacheOperations, ICachingInstrumentationProvider instrumentationProvider) { this.numberToRemoveWhenScavenging = numberToRemoveWhenScavenging; this.maximumElementsInCacheBeforeScavenging = maximumElementsInCacheBeforeScavenging; this.cacheOperations = cacheOperations; this.instrumentationProvider = instrumentationProvider; }
/// <summary> /// Initialize a new instance of the <see cref="ScavengerTask"/> with a <see cref="CacheManager"/> name, the <see cref="CacheCapacityScavengingPolicy"/> and the <see cref="ICacheOperations"/>. /// </summary> /// <param name="numberToRemoveWhenScavenging">The number of items that should be removed from the cache when scavenging.</param> /// <param name="maximumElementsInCacheBeforeScavenging"></param> /// <param name="cacheOperations">The <see cref="ICacheOperations"/> to perform.</param> /// <param name="instrumentationProvider">An instrumentation provider.</param> public ScavengerTask(int numberToRemoveWhenScavenging, int maximumElementsInCacheBeforeScavenging, ICacheOperations cacheOperations, ICachingInstrumentationProvider instrumentationProvider) { this.numberToRemoveWhenScavenging = numberToRemoveWhenScavenging; this.maximumElementsInCacheBeforeScavenging = maximumElementsInCacheBeforeScavenging; this.cacheOperations = cacheOperations; this.instrumentationProvider = instrumentationProvider; }
/// <summary> /// </summary> /// <param name="backingStore">Резервное хранилище.</param> /// <param name="instrumentationProvider">Инструментарий для событий</param> public Cache(IBackingStore backingStore, ICachingInstrumentationProvider instrumentationProvider) { if (backingStore == null) throw new ArgumentNullException("backingStore"); if (instrumentationProvider == null) throw new ArgumentNullException("instrumentationProvider"); this.backingStore = backingStore; this.instrumentationProvider = instrumentationProvider; var initialItems = backingStore.Load(); inMemoryCache = Hashtable.Synchronized(initialItems); this.instrumentationProvider.FireCacheUpdated(initialItems.Count, initialItems.Count); }
public CacheInstrumentation(ICache inner, ICachingInstrumentationProvider instrumentationProvider) { if (inner == null) { throw new ArgumentNullException("inner"); } if (instrumentationProvider == null) { throw new ArgumentNullException("instrumentationProvider"); } m_inner = inner; m_instrumentationProvider = instrumentationProvider; }
/// <summary> /// Initialzie a new instance of a <see cref="Cache"/> class with a backing store, and scavenging policy. /// </summary> /// <param name="backingStore">The cache backing store.</param> /// <param name="instrumentationProvider">The instrumentation provider.</param> public Cache(IBackingStore backingStore, ICachingInstrumentationProvider instrumentationProvider) { if (backingStore == null) { throw new ArgumentNullException("backingStore"); } if (instrumentationProvider == null) { throw new ArgumentNullException("instrumentationProvider"); } this.backingStore = backingStore; this.instrumentationProvider = instrumentationProvider; Hashtable initialItems = backingStore.Load(); inMemoryCache = Hashtable.Synchronized(initialItems); this.instrumentationProvider.FireCacheUpdated(initialItems.Count, initialItems.Count); }
/// <summary> /// Вызов рефреша в нити /// </summary> /// <param name="removedCacheItem">Удаляемый кэш-элемент. Не null.</param> /// <param name="removalReason">Причина удаления.</param> /// <param name="instrumentationProvider"></param> public static void InvokeRefreshAction(CacheItem removedCacheItem, CacheItemRemovedReason removalReason, ICachingInstrumentationProvider instrumentationProvider) { if (removedCacheItem == null) throw new ArgumentNullException("removedCacheItem"); if (instrumentationProvider == null) throw new ArgumentNullException("instrumentationProvider"); if (removedCacheItem.RefreshAction == null) { return; } try { var refreshActionData = new RefreshActionData(removedCacheItem.RefreshAction, removedCacheItem.Key, removedCacheItem.Value, removalReason, instrumentationProvider); refreshActionData.InvokeOnThreadPoolThread(); } catch (Exception e) { instrumentationProvider.FireCacheFailed(Resources.FailureToSpawnUserSpecifiedRefreshAction, e); } }
public void SetUp() { formatter = new NoPrefixNameFormatter(); formattedInstanceName = formatter.CreateName(instanceName); enabledProvider = new CachingInstrumentationProvider(instanceName, true, true, formatter); cacheHitsCounter = CreatePerformanceCounter("Cache Hits/sec", formattedInstanceName); cacheHitsCounter.RawValue = 0; cacheMissesCounter = CreatePerformanceCounter("Cache Misses/sec", formattedInstanceName); cacheMissesCounter.RawValue = 0; cacheHitRatioCounter = CreatePerformanceCounter("Cache Hit Ratio", formattedInstanceName); cacheHitRatioCounter.RawValue = 0; cacheAccessAttemptsCounter = CreatePerformanceCounter("Total # of Cache Access Attempts", formattedInstanceName); cacheAccessAttemptsCounter.RawValue = 0; cacheExpiriesCounter = CreatePerformanceCounter("Cache Expiries/sec", formattedInstanceName); cacheExpiriesCounter.RawValue = 0; cacheScavengedItemsCounter = CreatePerformanceCounter("Cache Scavenged Items/sec", formattedInstanceName); cacheScavengedItemsCounter.RawValue = 0; cacheTotalEntriesCounter = CreatePerformanceCounter("Total Cache Entries", formattedInstanceName); cacheTotalEntriesCounter.RawValue = 0; cacheUpdatedEntriesCounter = CreatePerformanceCounter("Updated Entries/sec", formattedInstanceName); cacheUpdatedEntriesCounter.RawValue = 0; totalCacheExpiriesCounter = CreatePerformanceCounter(CachingInstrumentationProvider.TotalCacheExpiriesCounterName, formattedInstanceName); totalCacheExpiriesCounter.RawValue = 0; totalCacheHitsCounter = CreatePerformanceCounter(CachingInstrumentationProvider.TotalCacheHitsCounterName, formattedInstanceName); totalCacheHitsCounter.RawValue = 0; totalCacheMissesCounter = CreatePerformanceCounter(CachingInstrumentationProvider.TotalCacheMissesCounterName, formattedInstanceName); totalCacheMissesCounter.RawValue = 0; totalCacheScavengedItemsCounter = CreatePerformanceCounter(CachingInstrumentationProvider.TotalCacheScavengedItemsCounterName, formattedInstanceName); totalCacheScavengedItemsCounter.RawValue = 0; totalUpdatedEntriesItemsCounter = CreatePerformanceCounter(CachingInstrumentationProvider.TotalUpdatedEntriesItemsCounterName, formattedInstanceName); totalUpdatedEntriesItemsCounter.RawValue = 0; }
public void SetUp() { formatter = new NoPrefixNameFormatter(); formattedInstanceName = formatter.CreateName(instanceName); enabledProvider = new CachingInstrumentationProvider(instanceName, true, true, formatter); cacheHitsCounter = CreatePerformanceCounter("Cache Hits/sec", formattedInstanceName); cacheHitsCounter.RawValue = 0; cacheMissesCounter = CreatePerformanceCounter("Cache Misses/sec", formattedInstanceName); cacheMissesCounter.RawValue = 0; cacheHitRatioCounter = CreatePerformanceCounter("Cache Hit Ratio", formattedInstanceName); cacheHitRatioCounter.RawValue = 0; cacheAccessAttemptsCounter = CreatePerformanceCounter("Total # of Cache Access Attempts", formattedInstanceName); cacheAccessAttemptsCounter.RawValue = 0; cacheExpiriesCounter = CreatePerformanceCounter("Cache Expiries/sec", formattedInstanceName); cacheExpiriesCounter.RawValue = 0; cacheScavengedItemsCounter = CreatePerformanceCounter("Cache Scavenged Items/sec", formattedInstanceName); cacheScavengedItemsCounter.RawValue = 0; cacheTotalEntriesCounter = CreatePerformanceCounter("Total Cache Entries", formattedInstanceName); cacheTotalEntriesCounter.RawValue = 0; cacheUpdatedEntriesCounter = CreatePerformanceCounter("Updated Entries/sec", formattedInstanceName); cacheUpdatedEntriesCounter.RawValue = 0; totalCacheExpiriesCounter = CreatePerformanceCounter(CachingInstrumentationProvider.TotalCacheExpiriesCounterName, formattedInstanceName); totalCacheExpiriesCounter.RawValue = 0; totalCacheHitsCounter = CreatePerformanceCounter(CachingInstrumentationProvider.TotalCacheHitsCounterName, formattedInstanceName); totalCacheHitsCounter.RawValue = 0; totalCacheMissesCounter = CreatePerformanceCounter(CachingInstrumentationProvider.TotalCacheMissesCounterName, formattedInstanceName); totalCacheMissesCounter.RawValue = 0; totalCacheScavengedItemsCounter = CreatePerformanceCounter(CachingInstrumentationProvider.TotalCacheScavengedItemsCounterName, formattedInstanceName); totalCacheScavengedItemsCounter.RawValue = 0; totalUpdatedEntriesItemsCounter = CreatePerformanceCounter(CachingInstrumentationProvider.TotalUpdatedEntriesItemsCounterName, formattedInstanceName); totalUpdatedEntriesItemsCounter.RawValue = 0; }
/// <summary> /// Initialize an instance of the <see cref="ExpirationTask"/> class with an <see cref="ICacheOperations"/> object. /// </summary> /// <param name="cacheOperations">An <see cref="ICacheOperations"/> object.</param> /// <param name="instrumentationProvider">An instrumentation provider.</param> public ExpirationTask(ICacheOperations cacheOperations, ICachingInstrumentationProvider instrumentationProvider) { this.cacheOperations = cacheOperations; this.instrumentationProvider = instrumentationProvider; }
/// <summary> /// Initialize a new instance of the <see cref="BackgroundScheduler"/> with a <see cref="ExpirationTask"/> and /// a <see cref="ScavengerTask"/>. /// </summary> /// <param name="expirationTask">The expiration task to use.</param> /// <param name="scavengerTask">The scavenger task to use.</param> /// <param name="instrumentationProvider">The instrumentation provider to use.</param> public BackgroundScheduler(ExpirationTask expirationTask, ScavengerTask scavengerTask, ICachingInstrumentationProvider instrumentationProvider) { this.expirationTask = expirationTask; this.scavengerTask = scavengerTask; this.instrumentationProvider = instrumentationProvider; }
public RaceConditionSimulatingExpirationTask(ICacheOperations cacheOperations, ICachingInstrumentationProvider instrumentationProvider) : base(cacheOperations, instrumentationProvider) { }
/// <summary> /// Invokes the refresh action on a thread pool thread /// </summary> /// <param name="removedCacheItem">Cache item being removed. Must never be null.</param> /// <param name="removalReason">The reason the item was removed.</param> /// <param name="instrumentationProvider">The instrumentation provider.</param> public static void InvokeRefreshAction(CacheItem removedCacheItem, CacheItemRemovedReason removalReason, ICachingInstrumentationProvider instrumentationProvider) { if (removedCacheItem == null) { throw new ArgumentNullException("removedCacheItem"); } if (instrumentationProvider == null) { throw new ArgumentNullException("instrumentationProvider"); } if (removedCacheItem.RefreshAction == null) { return; } try { RefreshActionData refreshActionData = new RefreshActionData(removedCacheItem.RefreshAction, removedCacheItem.Key, removedCacheItem.Value, removalReason, instrumentationProvider); refreshActionData.InvokeOnThreadPoolThread(); } catch (Exception e) { instrumentationProvider.FireCacheFailed(Resources.FailureToSpawnUserSpecifiedRefreshAction, e); } }
/// <summary> /// Initialize an instance of the <see cref="ExpirationTask"/> class with an <see cref="ICacheOperations"/> object. /// </summary> /// <param name="cacheOperations">An <see cref="ICacheOperations"/> object.</param> /// <param name="instrumentationProvider">An instrumentation provider.</param> public ExpirationTask(ICacheOperations cacheOperations, ICachingInstrumentationProvider instrumentationProvider) { this.cacheOperations = cacheOperations; this.instrumentationProvider = instrumentationProvider; }
/// <param name="expirationTask">Задание для экспиратора</param> /// <param name="scavengerTask">Задание для сборщика</param> /// <param name="instrumentationProvider"></param> public BackgroundScheduler(ExpirationTask expirationTask, ScavengerTask scavengerTask, ICachingInstrumentationProvider instrumentationProvider) { this.expirationTask = expirationTask; this.scavengerTask = scavengerTask; this.instrumentationProvider = instrumentationProvider; }
public Cache(IBackingStore backingStore, ICachingInstrumentationProvider instrumentationProvider);