• Webinars
  • Docs
  • Download
  • Blogs
  • Contact Us
Try Free
Show / Hide Table of Contents

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 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 as 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:

Install-Package StackExchange.Redis.Wrapper.NCache

Step 2: Add the Namespace to your Application

Next, replace the StackExchange.Redis namespace with NCache.StackExchange.Redis in your application, as shown below:

using NCache.StackExchange.Redis

Step 3: Connection with NCache

Note

Ensure 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, as shown below:
ConnectionMultiplexer ncache = ConnectionMultiplexer.Connect("demoCache");
  • Next, to get an instance of the 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.

Additional Resources

NCache provides code for StackExchange.Redis wrapper library and sample application on GitHub.

See Also

Migrate from AppFabric to NCache
Memcached Wrapper and Gateway Support for NCache
NCache as IdentityServer4 Cache and Data Store
.NET API Reference for NCache

Back to top Copyright © 2017 Alachisoft