ASP.NET Core – Distributed cache of cache
ASP.NET Core – Distributed cache of cache A distributed cache is a cache shared by multiple application servers and is typically maintained as an external service to the application servers that access it. Distributed caching can improve the performance and scalability of ASP.NET Core applications, especially when the application is hosted by a cloud service or server farm. Distributed caching has several advantages over other caching solutions that store cached data on a single application server. When distributing cached data, data: Maintain consistency (consistency) across requests from multiple servers. Still valid after server restart and application deployment. Does not use local memory. 1. Use of distributed cache The use of distributed cache under the .NET Core framework is based on the IDistributedCache interface, which abstracts and unifies the use of distributed cache. Its access to cached data is based on byte[]. The IDistributedCache interface provides the following methods for handling items in distributed cache implementations: Get, GetAsync: Accepts a string key and retrieves the cache item as a byte[] array if found in the cache. Set, SetAsync: Add an item (as a byte[] array) to the cache using a string key. Refresh, RefreshAsync: Refresh an item in the cache based…