• Facebook
  • Twitter
  • Youtube
  • LinedIn
  • RSS
  • Docs
  • Comparisons
  • Blogs
  • Download
  • Contact Us
Download
Show / Hide Table of Contents

NCache as CacheManager.Core Provider

The NCache CacheManager.Core integration allows CacheManager.Core applications to use NCache as a distributed cache handle and as a backplane for cache invalidation. The integration provides NCacheCacheHandle<T> for cache operations and NCacheCacheBackplane for cache change notifications across application instances.

NCache is configured in CacheManager.Core by passing an NCacheOptions instance during cache handle and backplane registration.

Note

This feature is supported only in the NCache OpenSource edition.

Important

Tag-based eviction is not supported in the CacheManager.Core integration with NCache.

Prerequisites

Before configuring NCache with CacheManager.Core, make sure the following prerequisites are fulfilled:

  • .NET
  • Install the following NuGet package in your .NET application:
    • OpenSource: NCache.OSS.CacheManager.Core
  • Include the following namespaces in your application:
    • CacheManager.Core
    • NCache.OSS.CacheManager.Core
    • Microsoft.Extensions.DependencyInjection
    • Microsoft.Extensions.Logging
  • The NCache cache must already exist and must be running.
  • Configure ServerList when the application connects to a remote or distributed NCache deployment.
  • Make sure that the data being added to the cache is serializable.

Configure NCache with CacheManager.Core

The following example configures CacheManager.Core with:

  • A dictionary cache handle.
  • An NCache distributed cache handle.
  • An NCache backplane for cache invalidation.

Add the following code to your Program.cs file.

using CacheManager.Core;
using NCache.OSS.CacheManager.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

var services = new ServiceCollection();

services.AddLogging(cfg =>
{
    cfg.AddConsole();
    cfg.SetMinimumLevel(LogLevel.Information);
});

var provider = services.BuildServiceProvider();
var loggerFactory = provider.GetRequiredService<ILoggerFactory>();

var options = new NCacheOptions
{
    CacheName = "demoCache",
    ServerList = new List<NCacheOptions.ServerConfig>
    {
        new NCacheOptions.ServerConfig
        {
            Ip = "20.200.20.39",
            Port = 9800
        }
    }
};

var cache = CacheFactory.Build<string>("myCache", settings =>
{
    settings.WithDictionaryHandle();

    settings.WithHandle(
        typeof(NCacheCacheHandle<>),
        "cache_handle_name",
        true,
        options);

    settings.WithBackplane(
        typeof(NCacheCacheBackplane),
        "ncache_config_key",
        "example_topic_name",
        options);
},
loggerFactory);

In this configuration:

  • WithDictionaryHandle() configures an in-memory cache handle.
  • WithHandle(...) configures NCache as a CacheManager.Core cache handle.
  • WithBackplane(...) configures the NCache backplane for cache invalidation notifications.
  • NCacheOptions provides the NCache cache name and server connectivity details.

Configuration Properties

The following configuration properties are available in the NCacheOptions class.

Property Description
CacheName* Specifies the name of the NCache cache instance. The cache must already exist and must be running. This property is required for initialization.
ServerList Specifies the list of NCache server nodes used for cache connectivity. Each entry contains an IP address and port. If the port is not specified, the default NCache client port 9800 is used.
Note

The properties marked with an asterisk (*) are required.

ServerConfig Properties

Each ServerList entry uses the NCacheOptions.ServerConfig class.

Property Description
Ip* Specifies the IP address of the NCache server node. The value must be a valid IPv4 or IPv6 address.
Port Specifies the NCache client port. The value must be between 1 and 65535. The default value is 9800.
Note

If CacheName is invalid, the cache is not running, or the server configuration is incorrect, provider initialization fails.

See Also

CacheManager.Core API Usage

Contact Us

PHONE

+1 214-619-2601   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

Deployments
  • Cloud (SaaS & Software)
  • On-Premises
  • Kubernetes
  • Docker
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • Real-Time ASP.NET SignalR
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Magazine Articles
  • Third-Party Articles
  • Articles
  • Videos
  • Whitepapers
  • Shows
  • Talks
  • Blogs
  • Docs
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Schedule a Demo
  • Forum (Google Groups)
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top