diff --git a/src/Orchard.Web/Modules/Orchard.Redis/Caching/RedisCacheStorageProvider.cs b/src/Orchard.Web/Modules/Orchard.Redis/Caching/RedisCacheStorageProvider.cs index 5f3c8896d..ad4f720b5 100644 --- a/src/Orchard.Web/Modules/Orchard.Redis/Caching/RedisCacheStorageProvider.cs +++ b/src/Orchard.Web/Modules/Orchard.Redis/Caching/RedisCacheStorageProvider.cs @@ -10,9 +10,13 @@ using System; namespace Orchard.Redis.Caching { + public interface IRedisCacheStorageProvider : ICacheStorageProvider { + void Clear(string key); + } + [OrchardFeature("Orchard.Redis.Caching")] [OrchardSuppressDependency("Orchard.Caching.Services.DefaultCacheStorageProvider")] - public class RedisCacheStorageProvider : Component, ICacheStorageProvider { + public class RedisCacheStorageProvider : Component, IRedisCacheStorageProvider { public const string ConnectionStringKey = "Orchard.Redis.Cache"; private readonly ShellSettings _shellSettings; @@ -61,6 +65,10 @@ namespace Orchard.Redis.Caching { _connectionMultiplexer.KeyDeleteWithPrefix(GetLocalizedKey("*")); } + public void Clear(string key) { + _connectionMultiplexer.KeyDeleteWithPrefix(GetLocalizedKey($"{_shellSettings.Name}:{key}")); + } + private string GetLocalizedKey(string key) { return _shellSettings.Name + ":Cache:" + key; }