/// <summary> /// Removes items from cache that have keys matching the specified wildcard pattern /// </summary> /// <param name="cacheClient">Cache client</param> /// <param name="pattern">The wildcard, where "*" means any sequence of characters and "?" means any single character.</param> /// <param name="token"></param> public static Task RemoveByPatternAsync(this ICacheClientAsync cacheClient, string pattern, CancellationToken token = default) { if (!(cacheClient is IRemoveByPatternAsync canRemoveByPattern)) { throw new NotImplementedException( "IRemoveByPattern is not implemented on: " + cacheClient.GetType().FullName); } return(canRemoveByPattern.RemoveByPatternAsync(pattern, token)); }
/// <summary> /// Removes items from the cache based on the specified regular expression pattern /// </summary> /// <param name="cacheClient">Cache client</param> /// <param name="regex">Regular expression pattern to search cache keys</param> public static Task RemoveByRegexAsync(this ICacheClientAsync cacheClient, string regex) { if (!(cacheClient is IRemoveByPatternAsync canRemoveByPattern)) { throw new NotImplementedException("IRemoveByPattern is not implemented by: " + cacheClient.GetType().FullName); } return(canRemoveByPattern.RemoveByRegexAsync(regex)); }