Data Caching in .NET Sample Application
NCache provides a sample application for .NET on GitHub. This section will guide you through setting up and using this data caching sample application.
Important
To learn about the supported .NET versions, please refer to the NCache Installation Guide.
NCache Demonstration for .NET Data Caching Sample
Follow the steps mentioned here to see how NCache is used to perform various operations on your .NET application's data.
Step 1: Download Sample from GitHub
Go to the NCache repository on GitHub and download the entire repository or the data caching sample you are interested in.
Step 2: Launch the Project
Launch your .NET data caching sample application in Visual Studio 2022 or above.
Step 3: Configure Settings
After launching the project, locate and open the App.config file where you have to change the name of your cache to the one created before.
Step 4: Build and Run Sample
After configuring the cache settings, build the sample application for further use.
Important
Threadpool Setting for .NET 8.0
For Windows, it is essential to set the
UseWindowsThreadPool
flag to true. For already built applications, set theUseWindowsThreadPool
flag in runtimeconfig.json file:{ "runtimeOptions": { "configProperties": { "System.Threading.ThreadPool.UseWindowsThreadPool": true } } }
During development phase, this file will be overwritten with each compilation. Therefore, define the
UseWindowsThreadPool
property in the project file instead, as follows:<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <UseWindowsThreadPool>true</UseWindowsThreadPool> </PropertyGroup> </Project>
To learn more about the
UseWindowsThreadPool
flag, click here.For Linux, it is mandatory to set the
MinimumThreads
flag to a value of 100 in the runtimeconfig.json, as follows:{ "runtimeOptions": { "configProperties": { "System.Threading.ThreadPool.MinThreads": 100 } } }
To learn more about the
MinThreads
flag, click here.
Step 5: Monitor NCache
Go to the NCache Management Center, and against the cache you have created previously, click on Monitor. You will see the counters dashboard projecting the change in the cache.
See Also
Create Distributed Cache
Create Distributed Cache with Persistence
Use NCache for ASP.NET Core Sessions