
Net Core framework and ASP.NET Core Version 3.1 as the framework for application and few advance settings for such as configuring https and enabling docker we are not going to enable docker settings for this project. Next, we are going to set Project Name “ WebCacheDemo” and location. Let’s start with creating an application.
Implementing Refresh, RefreshAsync methods. Implementing Remove, RemoveAsync methods. Implementing Get, GetAsync, GetString, GetStringAsync methods. Using RedisDesktopManager to View stored Cache on Azure. Implementing Set, SetAsync, SetString ,SetStringAsync methods. Adding DemoController and injecting IDistributedCache for accessing method. Adding “ AddDistributedRedisCache” method in the ConfigureServices method. Adding Access Keys to appsettings.json file. Creating a Resource “Azure Cache for Redis” on Azure. Installing package from NuGet package.
Creating application ASP.NET Core Application. Azure Cache for Redis is managed by Microsoft, hosted within Azure, and accessible to any application within or outside of Azure. We are going to use “ Azure Cache for Redis” to store and retrieve data from the Cache.Īzure Cache for Redis provides you access to a secure, dedicated Redis cache. Now whenever a user will access the menu, he will hit Cache not database this will help you reduce hits on Database. Another way will be you can add new menu store it in the Database and then load all menus into the Cache. Its is better to store all menus data in the Cache and set an expiry date to it. If you have large application and role wise menus stored in the Database which are shown to the user as they login these menus does not change frequently, meanwhile think if the number of users accessing the application at once are in thousands each time you will hit the Database to get data you which will create unusual load on SQL database for getting static data. The Cache is used to cache data which is frequently used and which does not change often. Idatabase redis how to#
In this article, we are going to learn how to Use Redis cache with ASP.NET Core using the package “ ” provided by Microsoft.