• Facebook
  • Twitter
  • Youtube
  • LinkedIn
  • RSS
  • Docs
  • Comparisons
  • Blogs
  • Try NCache
  • Contact Us
Try NCache
Show / Hide Table of Contents

NCache as FusionCache Backplane Provider

The NCache Backplane integration for FusionCache enables cache synchronization across multiple application nodes by using NCache as the messaging layer. In a distributed application, each application instance maintains its own local in-memory Layer 1 (L1) cache. While this provides fast access, it can also cause stale data if one node updates or removes an entry and other nodes continue serving the older value from their local memory.

Note

This feature is currently supported in the NCache Open Source edition.

Important

FusionCache is supported in NCache 5.3.6.2 and onwards.

When NCache is configured as a FusionCache Backplane provider, FusionCache publishes cache change notifications through NCache. Other application nodes receive these notifications and update, remove, expire, or invalidate their local L1 cache entries accordingly.

Note

The FusionCache Backplane does not store cached data. It only transports cache synchronization notifications between application nodes. Cached data is stored in FusionCache L1 and, if configured, in the distributed L2 cache.

In most multi-node FusionCache deployments, NCache should be configured both as the distributed L2 cache and as the Backplane provider. The L2 cache stores cached data through IDistributedCache, while the Backplane publishes synchronization notifications across application nodes. This combination helps avoid unnecessary database calls when a Backplane notification is received and FusionCache needs to check the distributed cache state.

How NCache Works as a FusionCache Backplane

The NCache Backplane operates as a Pub/Sub-based synchronization layer. Each application node connects to NCache and subscribes to the Backplane channel used by FusionCache. When a cache-changing operation occurs on one node, FusionCache publishes a notification through NCache. Other subscribed nodes receive the notification and apply the corresponding change to their local L1 cache.

This is different from using NCache only as an L2 cache. When NCache is used only as IDistributedCache, cached values are shared through the L2 cache, but local L1 entries on other nodes are not immediately synchronized. The Backplane adds this synchronization layer by broadcasting cache change notifications across the application nodes.

For a complete multi-node FusionCache setup, configure NCache as both the distributed L2 cache and the Backplane provider. The distributed L2 cache stores the cached values, while the Backplane keeps the local L1 cache entries synchronized across application nodes.

Prerequisites

Before configuring NCache as the FusionCache Backplane provider, ensure that the following prerequisites are fulfilled:

  • .NET
  • Install the following NuGet packages in your application:
    • NCache L2 Provider: NCache.Microsoft.Extensions.Caching.Opensource
    • NCache Backplane Provider: NCache.OSS.ZiggyCreatures.FusionCache.Backplane
    • FusionCache: ZiggyCreatures.FusionCache
    • Serializer: ZiggyCreatures.FusionCache.Serialization.SystemTextJson
  • To use NCache as both the FusionCache distributed L2 cache and Backplane provider, include the following namespaces in Program.cs:
    • Alachisoft.NCache.Caching.Distributed
    • Alachisoft.NCache.Caching.Distributed.Configuration
    • Microsoft.Extensions.Options
    • NCache.ZiggyCreatures.FusionCache.Backplane
    • NCache.ZiggyCreatures.FusionCache.Backplane.Configuration
    • Microsoft.Extensions.Logging
    • ZiggyCreatures.Caching.Fusion
    • ZiggyCreatures.Caching.Fusion.Serialization.SystemTextJson
  • You must have L1, L2, and Backplane cache connectivity available:
    • L1 cache: FusionCache’s in-process memory cache inside each application instance.
    • L2 cache: NCache distributed cache used to store cached data through IDistributedCache.
    • Backplane cache: NCache cache used for Backplane communication.
  • Each application node that participates in FusionCache synchronization must be able to connect to the same NCache cache.
  • The data being added to the cache must be serializable when FusionCache is configured with a distributed cache.
Note

When using the NCache 5.3.800 SDK, configure NCache client retries, timeouts, Keep Alive, and load balancing on the cache server under <client-settings><connection-options>. Configure NCache client logging under <client-settings><logging>. The server supplies these settings after the client connects. The corresponding legacy properties on NCacheBackplaneOptions do not override them.

Method 1: Explicit Configuration

In this approach, you provide the server endpoints, local client binding IP, and application name through NCacheBackplaneOptions. The provider uses these values when it connects to the cache for Backplane communication.

var backplaneOptions = new NCacheBackplaneOptions
{
    ServerList = new List<FusionCacheServerInfo>
    {
        new FusionCacheServerInfo("20.200.20.11")
    },
    ClientBindIP = "20.200.20.12",
    AppName = "FusionCache-App"
};

Then configure FusionCache to use NCache as both the distributed L2 cache and the Backplane provider.

var cacheName = "fusionCache";

var distributedCacheConfig = new NCacheConfiguration
{
    CacheName = cacheName,
    EnableLogs = true,
    ExceptionsEnabled = true
};

var distributedCacheOptions = Options.Create(distributedCacheConfig);

builder.Services
    .AddFusionCache()
    .WithOptions(options =>
    {
        options.BackplaneChannelPrefix = "my-app";
        options.BackplaneCircuitBreakerDuration = TimeSpan.FromSeconds(30);
    })
    .WithDefaultEntryOptions(new FusionCacheEntryOptions
    {
        Duration = TimeSpan.FromMinutes(5),
        IsFailSafeEnabled = true,
        FailSafeMaxDuration = TimeSpan.FromHours(2),
        FailSafeThrottleDuration = TimeSpan.FromSeconds(30),
        FactorySoftTimeout = TimeSpan.FromSeconds(2),
        FactoryHardTimeout = TimeSpan.FromSeconds(5),
        DistributedCacheSoftTimeout = TimeSpan.FromSeconds(2),
        DistributedCacheHardTimeout = TimeSpan.FromSeconds(5),
        AllowBackgroundDistributedCacheOperations = true,
        ReThrowDistributedCacheExceptions = false,
        ReThrowBackplaneExceptions = false,
        AllowBackgroundBackplaneOperations = true
    })
    .WithSerializer(new FusionCacheSystemTextJsonSerializer())
    .WithDistributedCache(new NCacheDistributedCache(distributedCacheOptions))
    .WithBackplane(
        new NCacheBackplane(
            cacheName: cacheName,
            options: backplaneOptions));

In this configuration, NCacheDistributedCache is used as FusionCache’s distributed L2 cache, while NCacheBackplane is used to publish synchronization notifications across application nodes.

Method 2: Using Default NCache Backplane Configuration

Use this approach when the application provides the Backplane cache's server endpoints through the ncache section of its application configuration. Create the Backplane with the cache name, and the NCache client reads the matching connection information from the application configuration. With the NCache 5.3.800 SDK, client tuning and client logging settings are supplied by the cache server.

var cacheName = "fusionCache";

var distributedCacheConfig = new NCacheConfiguration
{
    CacheName = cacheName,
    EnableLogs = true,
    ExceptionsEnabled = true
};

var distributedCacheOptions = Options.Create(distributedCacheConfig);

builder.Services
    .AddFusionCache()
    .WithDefaultEntryOptions(new FusionCacheEntryOptions
    {
        Duration = TimeSpan.FromMinutes(5),
        IsFailSafeEnabled = true,
        FailSafeMaxDuration = TimeSpan.FromHours(2),
        FailSafeThrottleDuration = TimeSpan.FromSeconds(30),
        FactorySoftTimeout = TimeSpan.FromSeconds(2),
        FactoryHardTimeout = TimeSpan.FromSeconds(5),
        DistributedCacheSoftTimeout = TimeSpan.FromSeconds(2),
        DistributedCacheHardTimeout = TimeSpan.FromSeconds(5),
        AllowBackgroundDistributedCacheOperations = true,
        ReThrowDistributedCacheExceptions = false,
        ReThrowBackplaneExceptions = false,
        AllowBackgroundBackplaneOperations = true
    })
    .WithSerializer(new FusionCacheSystemTextJsonSerializer())
    .WithDistributedCache(new NCacheDistributedCache(distributedCacheOptions))
    .WithBackplane(
        new NCacheBackplane(cacheName: cacheName));

In this configuration, FusionCache uses NCache as the distributed L2 cache, and the Backplane connects using the application configuration for the specified cache.

Note

The Backplane does not store cached data. It only transports synchronization notifications between FusionCache instances. For a complete multi-node FusionCache setup, configure NCache as the distributed L2 cache along with the Backplane provider.

Configure NCacheBackplaneOptions

The following properties provide application-specific connection information for the Backplane.

Property Description
ServerList Specifies the NCache server endpoints used by the Backplane provider.
ClientBindIP Specifies the local IP address used by the client when the application machine has multiple network interfaces.
AppName Identifies the Backplane's NCache client connection for monitoring and diagnostics.

The provider also retains the following properties. When using the NCache 5.3.800 SDK, setting them does not change the corresponding NCache client behavior. Configure the server-side settings for the Backplane cache instead. These settings apply to clients connecting to that cache.

Backplane Property Server-Side Client Setting
LoadBalance load-balance under <client-settings><connection-options>.
ClientRequestTimeOut client-request-timeout under <client-settings><connection-options>.
ConnectionTimeout connection-timeout under <client-settings><connection-options>.
ConnectionRetries connection-retries under <client-settings><connection-options>.
RetryInterval retry-interval under <client-settings><connection-options>.
RetryConnectionDelay retry-connection-delay under <client-settings><connection-options>.
EnableClientLogs enable-logs under <client-settings><logging>.
LogLevel log-level under <client-settings><logging>.

For the configuration syntax and units of these settings, see Client Connection Options and Client Logging.

Configure FusionCache Backplane Options

FusionCache also provides global Backplane options that control how Backplane notifications are handled.

builder.Services
    .AddFusionCache()
    .WithOptions(options =>
    {
        options.BackplaneChannelPrefix = "my-app";
        options.IgnoreIncomingBackplaneNotifications = false;
        options.EnableAutoRecovery = true;
        options.BackplaneCircuitBreakerDuration = TimeSpan.FromSeconds(30);
        options.ReThrowBackplaneExceptions = false;
        options.AllowBackgroundBackplaneOperations = true;
    });

Configuration Options

Options Description
BackplaneChannelPrefix Defines a unique channel or topic prefix for Backplane communication.
IgnoreIncomingBackplaneNotifications Determines whether incoming Backplane notifications should be ignored.
EnableAutoRecovery Enables automatic recovery after transient Backplane failures or disconnections.
BackplaneCircuitBreakerDuration Specifies how long FusionCache should pause Backplane operations after errors.
ReThrowBackplaneExceptions Controls whether Backplane exceptions should propagate to the application.
AllowBackgroundBackplaneOperations Allows Backplane notifications to execute asynchronously in the background.

Skip Backplane Notifications for Specific Operations

FusionCache also allows skipping Backplane notifications for a specific operation. This is useful when a cache change should remain local to the current node or when you do not want to notify other application nodes for a particular operation.

await cache.SetAsync(
    "product:1001",
    product,
    options => options.SetSkipBackplaneNotifications(true));

Logging

The Backplane provider accepts an ILogger<NCacheBackplane> through its constructor's logger parameter. Supply a logger from your application's logging configuration to capture Backplane diagnostic messages. In the following example, logger is an existing ILogger<NCacheBackplane>, and cacheName and backplaneOptions are the values configured earlier.

var backplane = new NCacheBackplane(
    cacheName: cacheName,
    options: backplaneOptions,
    logger: logger);

Pass this instance to .WithBackplane(backplane) in your FusionCache registration. The provider does not write its diagnostic messages through this logger when no logger is supplied.

NCache client logging is configured on the cache server; see Error Logging. With the NCache 5.3.800 SDK, the Backplane options EnableClientLogs and LogLevel do not override the server's client logging settings. FusionCache options such as circuit-breaker duration and operation timeouts remain configured through FusionCache as shown above.

Use detailed logging carefully in production because verbose logs can add overhead and increase log volume.

See Also

FusionCache with NCache
NCache as FusionCache Provider

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
Try NCache
Pricing
NCache Playground

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

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Terms of Use
  •  
  • Privacy Policy
  •  
  • Cookie Policy
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.
  • Facebook
  • Twitter
  • Youtube
  • LinkedIn
  • RSS