Cookie Consent by Free Privacy Policy Generator Redis API Wrapper for NCache - NCache

Redis API Wrapper for NCache

The NCache Redis API Wrapper enables .NET applications to migrate from StackExchange.Redis to NCache by changing only the namespace, requiring zero logic modifications. This wrapper provides a high-performance alternative to Redis on Windows and Linux, granting immediate access to enterprise features like Client Cache (In-Proc) and SQL-based querying without a full code rewrite. Redis API Wrapper is provided by NCache to facilitate a smooth transition for .NET applications currently using Redis. This wrapper allows developers to migrate their applications to NCache with minimal code modifications while benefiting from the powerful distributed caching features of NCache.

Key Benefits of Using Redis API Wrapper

The key benefits of using the Redis API Wrapper provided by NCache are listed below.

  1. Migration with Minimal Code Changes

    NCache's Redis API Wrapper allows developers to replace StackExchange.Redis with NCache.StackExchange.Redis, maintaining existing Redis commands while leveraging NCache's performance benefits. This reduces migration complexity and ensures a seamless transition.

  2. Native Windows and Linux Support

    NCache is developed in .NET, runs efficiently on both Windows and Linux, ensuring smooth integration across platforms. This allows applications to run on their preferred operating system without extra overhead. In contrast, Redis runs natively on Linux, while Windows support relies on WSL or unofficial ports, adding complexity.

  3. 100% Native Cache

    As an optimized .NET application, NCache performs better than Redis, which is mainly designed for Linux environments, in terms of compatibility and efficiency. This makes it an ideal choice for enterprises that rely on Microsoft technologies, providing better integration and performance.

  4. Client Cache for InProc Speed

    NCache provides a Client Cache (Near Cache) that stores frequently accessed data directly within your application's process memory. By utilizing this In-Proc Client Cache, the wrapper eliminates the TCP/IP network overhead associated with standard Redis calls. This brings data access speeds closer to local memory latency, significantly improving performance for read-intensive workloads.

Key Benefits of Using NCache API Directly

Using the NCache API directly provides you with the following advantages.

  1. Advanced SQL / LINQ Capabilities

    Supports SQL and LINQ queries to retrieve data flexibly and efficiently.

  2. Server-Side Code

    Enhances performance and consistency by supporting Read-Through, Write-Through, Cache Loader and Refresher.

  3. Enhanced Data Integrity

    NCache provides advanced Expiration, Synchronization, and Cache Dependency mechanisms to ensure data freshness, surpassing basic expiration policies of Redis.

Feature StackExchange.Redis (Standard) NCache Redis Wrapper
Operating System Native Linux (WSL/Ports for Windows) Native Windows & Linux
Threading Model Single-Threaded (Event Loop) Multi-Threaded (High Concurrency)
Local Caching Not Native (External logic required) In-Proc Client Cache (Near-Cache)
Querying Capabilities Key-Value Lookups only Distributed SQL & LINQ Support
Runtime Environment C-based / Non-Managed 100% Native .NET
Data Consistency TTL / Manual Expiration Database Sync (SQL, Oracle, Cosmos)
Scaling Architecture Master-Slave / Cluster Peer-to-Peer Dynamic Clustering

Steps to Migrate from Redis to NCache

Using the steps below, you can seamlessly migrate from Redis to NCache.

  1. Install the NCache Redis Wrapper NuGet Package

    Run the following command in the Package Manager Console:

    Install-Package StackExchange.Redis.Wrapper.NCache
  2. Update the Namespace

    Modify your code by replacing the Redis namespace in your application:

    using StackExchange.Redis;

    with:

    using NCache.StackExchange.Redis;
  3. Configure the Connection

    Ensure that NCache is properly configured and running. Then, update your application's configuration settings (ensure to update the cache name with your cache that you have created in the app.config file):

    <configuration>
        <appSettings>
            <add key="CacheId" value="demoCache"/>
        </appSettings>
    </configuration>
    

    Next, establish a connection in your application:

    ConnectionMultiplexer ncache = ConnectionMultiplexer.Connect("demoCache");
    IDatabase db = ncache.GetDatabase();
  4. After this, you will be able to connect your StackExchange.Redis application to the NCache and execute different caching operations.

Unlock the Full Potential of NCache

Switching from Redis to NCache enables applications to gain enterprise-level performance, better scalability, and enhanced data integrity. With features like distributed caching, server-side execution, and advanced querying, NCache stands out as a superior alternative to Redis for .NET applications.

What to Do Next?

Frequently Asked Questions (FAQ)

No. The wrapper is designed for a direct, frictionless replacement of the StackExchange.Redis library. You only need to update the NuGet package and change the namespace in your project; your existing caching logic remains untouched.

Yes. Unlike Redis, which is Linux-centric and requires WSL or unofficial ports for Windows, NCache is a 100% native .NET application. It runs natively on both Windows and Linux with full enterprise support.

The primary advantage is the Client Cache (Near-Cache) feature. By keeping frequently accessed data in the application's process memory, NCache eliminates the TCP/IP network latency associated with standard Redis calls, providing near-instant data access.

Yes. While the standard Redis API doesn't support SQL, NCache allows you to run distributed SQL and LINQ queries against the same data. By referencing the NCache API alongside the wrapper, you can perform complex searches (e.g., SELECT * FROM FQN.Product WHERE Category = 'Electronics') that are not possible in Redis.

© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.