diff --git a/Enyim.Caching/IMemcachedClient.cs b/Enyim.Caching/IMemcachedClient.cs index 9560fd1d..7adf8fa1 100644 --- a/Enyim.Caching/IMemcachedClient.cs +++ b/Enyim.Caching/IMemcachedClient.cs @@ -73,6 +73,7 @@ public interface IMemcachedClient : IDisposable bool Remove(string key); Task RemoveAsync(string key); + Task RemoveMultiAsync(params string[] keys); void FlushAll(); Task FlushAllAsync(); diff --git a/Enyim.Caching/MemcachedClient.cs b/Enyim.Caching/MemcachedClient.cs index 19c49d78..197b0eea 100755 --- a/Enyim.Caching/MemcachedClient.cs +++ b/Enyim.Caching/MemcachedClient.cs @@ -1055,12 +1055,35 @@ public bool Remove(string key) return ExecuteRemove(key).Success; } - //TODO: Not Implement public async Task RemoveAsync(string key) { return (await ExecuteRemoveAsync(key)).Success; } + public async Task RemoveMultiAsync(params string[] keys) + { + if (keys.Length > 0) + { + var tasks = new Task[keys.Length]; + + for (var i = 0; i < keys.Length; i++) + { + tasks[i] = ExecuteRemoveAsync(keys[i]); + } + + await Task.WhenAll(tasks); + + foreach (var task in tasks) + { + if (!(await task).Success) return false; + } + + return true; + } + + return false; + } + /// /// Retrieves multiple items from the cache. /// @@ -1416,20 +1439,20 @@ void IDistributedCache.Remove(string key) #region [ License information ] /* ************************************************************ - * + * * Copyright (c) 2010 Attila Kisk? enyim.com - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * ************************************************************/ #endregion diff --git a/Enyim.Caching/MemcachedClientT.cs b/Enyim.Caching/MemcachedClientT.cs index 3853a640..183561a3 100644 --- a/Enyim.Caching/MemcachedClientT.cs +++ b/Enyim.Caching/MemcachedClientT.cs @@ -210,6 +210,11 @@ public Task RemoveAsync(string key) return _memcachedClient.RemoveAsync(key); } + public Task RemoveMultiAsync(params string[] keys) + { + return _memcachedClient.RemoveMultiAsync(keys); + } + public bool Replace(string key, object value, int cacheSeconds) { return _memcachedClient.Replace(key, value, cacheSeconds); diff --git a/Enyim.Caching/NullMemcachedClient.cs b/Enyim.Caching/NullMemcachedClient.cs index 22d6721d..5056bc23 100644 --- a/Enyim.Caching/NullMemcachedClient.cs +++ b/Enyim.Caching/NullMemcachedClient.cs @@ -184,7 +184,12 @@ public bool Remove(string key) public Task RemoveAsync(string key) { - return Task.FromResult(false); + return Task.FromResult(false); + } + + public Task RemoveMultiAsync(params string[] keys) + { + return Task.FromResult(false); } public ServerStats Stats()