public static async Task <T> GetAsAsync <T>(
     this IDistributedCache cache,
     string key,
     CancellationToken token = default(CancellationToken))
 {
     return(await cache.GetAsAsync <T>(key, Encoding.UTF8, token : token));
 }
예제 #2
0
        /// <inheritdoc />
        public async Task <TCache> GetFromCacheAsync()
        {
            if (memoryCache != null && memoryCache.TryGetValue <TCache>(key, out var cached) && cached != null)
            {
                return(cached);
            }
            var data = await distributedCache.GetAsAsync <TCache>(key);

            if (data != null)
            {
                SetMemoryData(data);
            }
            return(data);
        }