コード例 #1
0
 /// <summary>
 /// Syncronous version of RemoveCacheByGroupAsync
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="group"></param>
 public static void RemoveCacheByGroup(this IDistributedCache cache, string group)
 {
     string[] keyList = cache.GetKeyGroup(group);
     if (keyList.Length > 0)
     {
         foreach (string key in keyList)
         {
             cache.Remove(key);
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// Asyncronously removes all key-value stores of a group in Redis
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="group"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 // Clear all cache by group
 public static async Task RemoveCacheByGroupAsync(this IDistributedCache cache, string group, CancellationToken token = default(CancellationToken))
 {
     token.ThrowIfCancellationRequested();
     string[] keyList = cache.GetKeyGroup(group);
     if (keyList.Length > 0)
     {
         foreach (string key in keyList)
         {
             await cache.RemoveAsync(key);
         }
     }
 }