abp
abp copied to clipboard
Distributed Cache Improvements
- [ ] Use distributed locking for GetOrAdd... methods. Currently, we are using in-process locking, which is fine, but doesn't prevent multiple write operations. That means if the data is read from database, multiple processes unnecessarily read it multiple times. This can be a good optimization. This should be optional and per cache, because it has a cost. We can add an attribute to cacheitem class, like
[UseDistributedLock]
to indicate it. - [ ] Implement in-memory cache layer. This would be good for rarely changing big data. I've implemented a similar thing manually for dynamic permissions (
DynamicPermissionDefinitionStore
andDynamicPermissionDefinitionStoreInMemoryCache
classes can be checked). This covers https://github.com/abpframework/abp/issues/3854 too. Note that we should enable this only for real distributed caches, not for the default memory cache - it is already in-memory. This should be optional and per cache, because it has a cost and not necessary for all objects. We can add an attribute to cacheitem class, like[UseInMemoryCacheLayer]
to indicate it. We can also benefit from cache server's (e.g. Redis) events to get notified when the cached item has changed (updated/deleted) if the server supports.
https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-7-preview-6/ .NET 7 has new caching option - Output caching. Is this maybe somehow applicable for caching system described here?
@leonkosak it is something different. It caches the whole HTTP response. We want to improve distributed cache in this issue.
@hikalkan, thanks. Is Output Cache relevant for abp? As I can see, Output cache is also possible solution for multi-instance environments (kubernetes): https://www.youtube.com/watch?v=WeHZ_NMC-Jo
Output cache can be used in every .NET project, including ABP-based ones. I suppose no specific point related to ABP here.
Consider using https://github.com/ZiggyCreatures/FusionCache that is implemented on top of memory and distributed cache with functionality you are thinking to implement: https://github.com/ZiggyCreatures/FusionCache/blob/main/docs/Comparison.md