public async Task KeyExpireAsync(IEnumerable <string> cacheKeys, int seconds) { var operationId = s_diagnosticListener.WriteSetCacheBefore(new BeforeSetRequestEventData(CachingProviderType.ToString(), Name, nameof(TrySetAsync), new Dictionary <string, object> { { "cacheKeys", cacheKeys } }, TimeSpan.FromSeconds(seconds))); Exception e = null; try { await BaseKeyExpireAsync(cacheKeys, seconds); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteSetCacheError(operationId, e); } else { s_diagnosticListener.WriteSetCacheAfter(operationId); } } }
public async Task <bool> ExistsAsync(string cacheKey) { var operationId = s_diagnosticListener.WriteExistsCacheBefore(new BeforeExistsRequestEventData(CachingProviderType.ToString(), Name, nameof(ExistsAsync), cacheKey)); Exception e = null; try { var flag = await BaseExistsAsync(cacheKey); return(flag); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteExistsCacheError(operationId, e); } else { s_diagnosticListener.WriteExistsCacheAfter(operationId); } } }
public async Task SetAllAsync <T>(IDictionary <string, T> value, TimeSpan expiration) { var operationId = s_diagnosticListener.WriteSetCacheBefore(new BeforeSetRequestEventData(CachingProviderType.ToString(), Name, nameof(SetAllAsync), value.ToDictionary(k => k.Key, v => (object)v.Value), expiration)); Exception e = null; try { await BaseSetAllAsync(value, expiration); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteSetCacheError(operationId, e); } else { s_diagnosticListener.WriteSetCacheAfter(operationId); } } }
public async Task <bool> TrySetAsync <T>(string cacheKey, T cacheValue, TimeSpan expiration) { var operationId = s_diagnosticListener.WriteSetCacheBefore(new BeforeSetRequestEventData(CachingProviderType.ToString(), Name, nameof(TrySetAsync), new Dictionary <string, object> { { cacheKey, cacheValue } }, expiration)); Exception e = null; try { return(await BaseTrySetAsync(cacheKey, cacheValue, expiration)); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteSetCacheError(operationId, e); } else { s_diagnosticListener.WriteSetCacheAfter(operationId); } } }
public async Task RemoveAllAsync(IEnumerable <string> cacheKeys) { var operationId = s_diagnosticListener.WriteRemoveCacheBefore(new BeforeRemoveRequestEventData(CachingProviderType.ToString(), Name, nameof(RemoveAllAsync), cacheKeys.ToArray())); Exception e = null; try { await BaseRemoveAllAsync(cacheKeys); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteRemoveCacheError(operationId, e); } else { s_diagnosticListener.WriteRemoveCacheAfter(operationId); } } }
public async Task RemoveByPrefixAsync(string prefix) { var operationId = s_diagnosticListener.WriteRemoveCacheBefore(new BeforeRemoveRequestEventData(CachingProviderType.ToString(), Name, nameof(RemoveByPrefixAsync), new[] { prefix })); Exception e = null; try { await BaseRemoveByPrefixAsync(prefix); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteRemoveCacheError(operationId, e); } else { s_diagnosticListener.WriteRemoveCacheAfter(operationId); } } }
public async Task <IDictionary <string, CacheValue <T> > > GetByPrefixAsync <T>(string prefix) { var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, nameof(GetByPrefixAsync), new[] { prefix })); Exception e = null; try { return(await BaseGetByPrefixAsync <T>(prefix)); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteGetCacheError(operationId, e); } else { s_diagnosticListener.WriteGetCacheAfter(operationId); } } }
public void Remove(string cacheKey) { var operationId = s_diagnosticListener.WriteRemoveCacheBefore(new BeforeRemoveRequestEventData(CachingProviderType.ToString(), Name, nameof(Remove), new[] { cacheKey })); Exception e = null; try { BaseRemove(cacheKey); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteRemoveCacheError(operationId, e); } else { s_diagnosticListener.WriteRemoveCacheAfter(operationId); } } }
public async Task <object> GetAsync(string cacheKey, Type type) { var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, "GetAsync_Type", new[] { cacheKey })); Exception e = null; try { return(await BaseGetAsync(cacheKey, type)); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteGetCacheError(operationId, e); } else { s_diagnosticListener.WriteGetCacheAfter(operationId); } } }
public async Task <CacheValue <T> > GetAsync <T>(string cacheKey, Func <Task <T> > dataRetriever, TimeSpan expiration) { var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, nameof(GetAsync), new[] { cacheKey }, expiration)); Exception e = null; try { return(await BaseGetAsync <T>(cacheKey, dataRetriever, expiration)); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteGetCacheError(operationId, e); } else { s_diagnosticListener.WriteGetCacheAfter(operationId); } } }
public async Task <IDictionary <string, CacheValue <T> > > GetAllAsync <T>(IEnumerable <string> cacheKeys) { var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, nameof(GetAllAsync), cacheKeys.ToArray())); Exception e = null; try { return(await BaseGetAllAsync <T>(cacheKeys)); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteGetCacheError(operationId, e); } else { s_diagnosticListener.WriteGetCacheAfter(operationId); } } }
public CacheValue <T> Get <T>(string cacheKey) { var operationId = s_diagnosticListener.WriteGetCacheBefore(new BeforeGetRequestEventData(CachingProviderType.ToString(), Name, nameof(Get), new[] { cacheKey })); Exception e = null; try { return(BaseGet <T>(cacheKey)); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteGetCacheError(operationId, e); } else { s_diagnosticListener.WriteGetCacheAfter(operationId); } } }
public async Task FlushAsync() { var operationId = s_diagnosticListener.WriteFlushCacheBefore(new EventData(CachingProviderType.ToString(), Name, nameof(FlushAsync))); Exception e = null; try { await BaseFlushAsync(); } catch (Exception ex) { e = ex; throw; } finally { if (e != null) { s_diagnosticListener.WriteFlushCacheError(operationId, e); } else { s_diagnosticListener.WriteFlushCacheAfter(operationId); } } }