MethodCache.Redis 1.0.0-rc.5

This is a prerelease version of MethodCache.Redis.
dotnet add package MethodCache.Redis --version 1.0.0-rc.5
                    
NuGet\Install-Package MethodCache.Redis -Version 1.0.0-rc.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MethodCache.Redis" Version="1.0.0-rc.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MethodCache.Redis" Version="1.0.0-rc.5" />
                    
Directory.Packages.props
<PackageReference Include="MethodCache.Redis" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MethodCache.Redis --version 1.0.0-rc.5
                    
#r "nuget: MethodCache.Redis, 1.0.0-rc.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MethodCache.Redis@1.0.0-rc.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MethodCache.Redis&version=1.0.0-rc.5&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MethodCache.Redis&version=1.0.0-rc.5&prerelease
                    
Install as a Cake Tool

MethodCache.Redis

Redis as MethodCache's distributed cache. Results are shared between application instances, and invalidations reach every instance's in-memory cache over Redis pub/sub.

Install it at the same version as MethodCache.

Usage

builder.Services.AddMethodCache(mc => mc.UseRedis("localhost:6379"));

With options:

builder.Services.AddMethodCache(mc => mc
    .UseRedis(options => options.Configuration = "redis1:6379,redis2:6379,password=...")
    .Distributed(options => options.KeyPrefix = "orders-api:"));   // data and backplane use the same final prefix

To share a connection your app already has instead:

builder.Services.AddMethodCache(mc => mc.UseRedis(options =>
    options.ConnectionMultiplexerFactory = sp => sp.GetRequiredService<IConnectionMultiplexer>()));
  • Set Configuration or ConnectionMultiplexerFactory. Startup fails when neither is set, so a missing configuration section never makes MethodCache connect to localhost.
  • MethodCache keeps its own cache and connection, so your app's IDistributedCache and Redis settings are left alone.
  • The connection opens on first use, on the thread pool, so the application starts while Redis is down and a slow connect never holds up a call.
  • MethodCache doesn't dispose a shared connection. Disposing the service provider removes MethodCache's own subscriptions.

How it works

  • MethodCache reads Redis on an in-memory miss and writes new results to both.
  • Invalidating a tag stores the time of the invalidation, and entries with that tag written before it are treated as missing, so no tag sets are kept in Redis. An older invalidation that arrives late never undoes a newer one.
  • Every invalidation is also published on the <prefix>invalidations channel, so every instance drops its in-memory copies at once.
  • Pub/sub delivers nothing while a connection is down. When the instance is subscribed again, it clears its in-memory cache. Reconnecting retries after 1 second, then twice as long each time, up to 30 seconds.

Memory and eviction

Invalidations are stored as keys beside the entries. If Redis evicts one under memory pressure, the entries it invalidated are served again until they expire. Set maxmemory-policy noeviction on the Redis MethodCache uses (or give it a Redis of its own) and give it enough memory. The volatile-* policies, the default of some managed Redis services, can evict them too. A full Redis with noeviction refuses writes, which MethodCache handles like an outage. See Keep invalidations from being evicted.

When Redis is down

MethodCache keeps answering from memory and your methods; Redis never fails or stalls a call. Each call is capped at OperationTimeout (1 second), Redis is skipped for CircuitBreakerDuration (10 seconds) after a failure, and invalidations are queued and retried instead of throwing. The first failure and the recovery are logged.

The distributed cache guide covers outages, consistency between instances, serialization and the DistributedCacheOptions that tune all of this. The exact behavior is in the distributed cache reference.

Options

Option Default Description
Configuration none StackExchange.Redis configuration string
ConnectionMultiplexerFactory none Returns an existing connection to share instead of opening one
EnableBackplane true Send invalidations to other instances over pub/sub

DistributedCacheOptions.KeyPrefix applies to values, invalidations and the channel. The first instance that uses a prefix fixes its minimum TagRetention; a shorter setting fails at startup, so use a new prefix to lower it.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-rc.5 0 11/4/2026
1.0.0-rc.4 0 11/4/2026
1.0.0-rc.3 5 11/4/2026
1.0.0-rc.2 62 10/20/2026
1.0.0-rc.1 69 10/19/2026