Skip to content

Alachisoft/Redis-Wrapper

Repository files navigation

NCache OSS Wrapper for StackExchange.Redis

A compatibility layer that enables .NET applications to use NCache as a drop-in replacement for Redis with the familiar StackExchange.Redis API.

Package Versions

Package Version
NCache.StackExchange.Redis 5.3.6.2
Alachisoft.NCache.SDK >= 5.3.6.2
Supported StackExchange.Redis >= 2.12.14

Installation

Install the package using the .NET CLI:

dotnet add package NCache.OSS.StackExchange.Redis.Wrapper --version 5.3.6.2

Or install it using the Package Manager Console:

Install-Package NCache.OSS.StackExchange.Redis.Wrapper -Version 5.3.6.2

Overview

NCache is an extremely fast and scalable distributed cache for .NET applications. This wrapper allows you to migrate from Redis to NCache with minimal code changes by providing implementations of the StackExchange.Redis interfaces.

Key Benefits:

  • Migrate from Redis to NCache without rewriting your application
  • Use familiar StackExchange.Redis API patterns
  • Leverage NCache's enterprise features (clustering, replication, persistence)
  • Maintain existing Redis-based code while gaining NCache performance

Getting Started

Prerequisites

Before using this package, ensure you have:

An NCache cache – created and running on the cluster.

1. Configure the cache name

The wrapper resolves which NCache cache to connect to from a single identifier, typically read from your app's configuration:

<appSettings>
  <add key="CacheId" value="democache" />
</appSettings>

2. Connect and get a database handle

using Alachisoft.NCache.Client;
using NCache.OSS.StackExchange.Redis;
using System.Configuration;

string cacheName = ConfigurationManager.AppSettings["CacheId"];

ConnectionMultiplexer mux = ConnectionMultiplexer.Connect(cacheName);
INCacheDatabase db = mux.GetDatabase();

mux and db behave like a standard StackExchange.Redis ConnectionMultiplexer/IDatabase pair, so existing Redis call sites — string get/set, key expiration and TTL, bulk operations, pub/sub, locks, and so on — work against db unchanged.

3. (Optional) Reach NCache-specific features

ICache cache = mux.GetNCacheInterface(cacheName);

GetNCacheInterface hands back the underlying NCache ICache, useful for operations outside the Redis surface for NCache-only capabilities.

4. (Optional) Wire up logging

using Microsoft.Extensions.Logging;

ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
{
    builder
        .AddConsole()
        .SetMinimumLevel(LogLevel.Debug);
});

NCache.StackExchange.Redis.Sample

The application acts as a test suite, targeting all APIs defined within the wrapper. Simply plug in your cache and run Program.cs.

License

Copyright © 2005-2026 Alachisoft. All rights reserved.

Resources

About

NCache provides a wrapper for StackExchange.Redis that allows you to migrate your .NET applications smoothly from Redis to NCache with minimal code change.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages