-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
117 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 8 additions & 4 deletions
12
...p.SettingManagement.Domain/Volo/Abp/SettingManagement/AbpSettingManagementDomainModule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ment/src/Volo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingCacheItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
|
||
namespace Volo.Abp.SettingManagement | ||
{ | ||
[Serializable] | ||
public class SettingCacheItem | ||
{ | ||
public string Value { get; set; } | ||
|
||
public SettingCacheItem() | ||
{ | ||
|
||
} | ||
|
||
public SettingCacheItem(string value) | ||
{ | ||
Value = value; | ||
} | ||
|
||
public static string CalculateCacheKey(string name, string providerName, string providerKey) | ||
{ | ||
return "pn:" + providerName + ",pk:" + providerKey + ",n:" + name; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...lo.Abp.SettingManagement.Domain/Volo/Abp/SettingManagement/SettingCacheItemInvalidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Threading.Tasks; | ||
using Volo.Abp.Caching; | ||
using Volo.Abp.DependencyInjection; | ||
using Volo.Abp.Domain.Entities.Events; | ||
using Volo.Abp.EventBus; | ||
|
||
namespace Volo.Abp.SettingManagement | ||
{ | ||
public class SettingCacheItemInvalidator : ILocalEventHandler<EntityChangedEventData<Setting>>, ITransientDependency | ||
{ | ||
protected IDistributedCache<SettingCacheItem> Cache { get; } | ||
|
||
public SettingCacheItemInvalidator(IDistributedCache<SettingCacheItem> cache) | ||
{ | ||
Cache = cache; | ||
} | ||
|
||
public virtual async Task HandleEventAsync(EntityChangedEventData<Setting> eventData) | ||
{ | ||
var cacheKey = CalculateCacheKey( | ||
eventData.Entity.Name, | ||
eventData.Entity.ProviderName, | ||
eventData.Entity.ProviderKey | ||
); | ||
|
||
await Cache.RemoveAsync(cacheKey); | ||
} | ||
|
||
protected virtual string CalculateCacheKey(string name, string providerName, string providerKey) | ||
{ | ||
return SettingCacheItem.CalculateCacheKey(name, providerName, providerKey); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters