Redis to NCache Migration
To seamlessly migrate from your already existing StackExchange.Redis client application, NCache provides a wrapper with the ease of minimal code and logic change along with its features. Follow the steps given below to learn how to migrate from Redis to NCache using the NCache wrapper for StackExchange.Redis.
Step 1: Download NCache Redis Wrapper NuGet Package
NCache provides the wrapper for StackExchange.Redis in the form of a NuGet package. To install NuGet package in your application, open Visual Studio, go to Tools -> NuGet Package Manager -> Package Manager Console. On the console window, type and execute the following command:
Step 2: Add the Namespace to your Application
Next, replace the
StackExchange.Redis namespace with
NCache.StackExchange.Redis in your application as shown below:
Step 3: Connection with NCache
Make sure that your cache is running.
- Replace the Server IP with the name of your cache that you have created in the App.config file.
<configuration> <appSettings> <add key="CacheId" value="demoCache"/> </appSettings> </configuration>
- Now, you need to connect with your cache using the ConnectionMultiplexer class which is the central object in the StackExchange.Redis API like below:
ConnectionMultiplexer ncache = ConnectionMultiplexer.Connect("cacheName");
- Next, to get an instance of NCache cache store write the following line:
IDatabase db = ncache.GetDatabase();
After completing these steps, you will be able to connect your StackExchange.Redis application to the NCache cache and execute different caching operations on it.
NCache provides code for StackExchange.Redis wrapper library and sample application on GitHub.