Metalama.Patterns.Caching
2026年1月19日
Prefix Reserved
dotnet add package Metalama.Patterns.Caching --version 2026年1月19日
NuGet\Install-Package Metalama.Patterns.Caching -Version 2026年1月19日
<PackageReference Include="Metalama.Patterns.Caching" Version="2026年1月19日" />
<PackageVersion Include="Metalama.Patterns.Caching" Version="2026年1月19日" />Directory.Packages.props
<PackageReference Include="Metalama.Patterns.Caching" />Project file
paket add Metalama.Patterns.Caching --version 2026年1月19日
#r "nuget: Metalama.Patterns.Caching, 2026年1月19日"
#:package Metalama.Patterns.Caching@2026年1月19日
#addin nuget:?package=Metalama.Patterns.Caching&version=2026年1月19日Install as a Cake Addin
#tool nuget:?package=Metalama.Patterns.Caching&version=2026年1月19日Install as a Cake Tool
Metalama Logo
About
The Metalama.Patterns.Caching package is a front-end library for caching. It simplifies caching method results and invalidating the cached results.
This package is designed for use with the Metalama.Patterns.Caching.Aspects package, which offers Metalama-based aspects for caching, cache invalidation, and cache key generation. However, the Metalama.Patterns.Caching package does not rely on the Metalama aspect framework, and it can be used independently or with another aspect framework.
Key Features
- Caching the return value of a method as a function of its arguments.
- Invalidation of cached method results, both directly and indirectly through cache dependencies.
- In-memory cache, Redis cache, Pub/Sub synchronized cache, L2 in-memory cache.
- Caching profiles for dynamically changing settings at runtime.
- Automatic reload of expired cached items.
- Cache key formatters through the
Flashtrace.Formatterspackage. - Value adapters for caching "special" types like streams or enumerables.
- Locking to prevent concurrent execution.
This package can interact with any cache implementation. The abstraction is provided by the CachingBackend class from the Metalama.Patterns.Caching.Backend package.
Main Types
The primary types in this package are:
- ICachingService is the main interface.
- CachingService is the primary implementation of
ICachingServiceand should generally not be directly used unless you are not using dependency injection. - CachingServiceFactory extends
IServiceCollectionand allows the addition ofICachingServiceto your application. - CachedMethodMetadata represents the metadata of a cached method. If you are not using an aspect framework, you must create an instance of this class for each cached method.
- CacheKeyBuilder is the algorithm that generates the cache key based on the method metadata and its arguments.
- IValueAdapter is the abstraction for caching special types like streams or enumerables.
Additional Documentation
Related Packages
Metalama.Patterns.Caching.Aspectsprovides an aspect-oriented API for the current package.Metalama.Patterns.Caching.Backenddefines the CachingBackend abstraction and provides core implementations for in-memory and multi-layered caching.Metalama.Patterns.Caching.Backends.Redisoffers theCachingBackendimplementation for Redis.Metalama.Patterns.Caching.Backends.Azureimplements pub/sub synchronization of distributed in-memory caches through Azure Message Bus.Flashtrace.Formattersprovides an infrastructure for cache key formatting.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- Flashtrace (>= 2026年1月19日)
- Flashtrace.Formatters (>= 2026年1月19日)
- Metalama.Patterns.Caching.Backend (>= 2026年1月19日)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- System.Collections.Immutable (>= 8.0.0)
- System.IO.Hashing (>= 9.0.15)
- System.Runtime.Serialization.Xml (>= 4.3.0)
- System.Text.Json (>= 9.0.10)
- System.Text.RegularExpressions (>= 4.3.1)
- System.Threading (>= 4.3.0)
- System.Threading.Tasks.Extensions (>= 4.5.4)
- System.Threading.Thread (>= 4.3.0)
- System.Threading.ThreadPool (>= 4.3.0)
-
.NETStandard 2.0
- Flashtrace (>= 2026年1月19日)
- Flashtrace.Formatters (>= 2026年1月19日)
- Metalama.Patterns.Caching.Backend (>= 2026年1月19日)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- System.Collections.Immutable (>= 8.0.0)
- System.IO.Hashing (>= 9.0.15)
- System.Text.Json (>= 9.0.10)
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
net8.0
- Flashtrace (>= 2026年1月19日)
- Flashtrace.Formatters (>= 2026年1月19日)
- Metalama.Patterns.Caching.Backend (>= 2026年1月19日)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- System.Collections.Immutable (>= 8.0.0)
- System.IO.Hashing (>= 9.0.15)
- System.Text.Json (>= 9.0.10)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Metalama.Patterns.Caching:
| Package | Downloads |
|---|---|
|
Shinya.Core
Shinya.Framework |
|
|
Metalama.Patterns.Caching.Aspects
A set of aspects that simplify the caching: [Cache] to cache a method result as a function of its parameters, [InvalidateCache] to invalidate the cache, or [CacheKey] to mark a cache key in a class. |
|
|
Metalama.Patterns.Caching.Backends.Redis
Redis back-end for Metalama.Patterns.Caching. Implements both caching and cache invalidation over Redis Pub/Sub |
|
|
Metalama.Patterns.Caching.Backends.Azure
Synchronizes the invalidation of distributed Metalama.Patterns.Caching caches over Azure Service Bus. |
|
|
Metalama.Patterns.Caching.TestHelpers
This package contains helper classes used when developing unit tests for new CachingBackend implementations. You don't need this package in any other scenarios. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026年1月19日 | 770 | 6/27/2026 |
| 2026年1月18日 | 1,183 | 6/10/2026 |
| 2026年1月17日 | 267 | 6/5/2026 |
| 2026年1月16日 | 525 | 6/3/2026 |
| 2026年1月15日-rc | 2,170 | 5/15/2026 |
| 2026年1月14日-rc | 544 | 5/13/2026 |
| 2026年1月13日-preview | 251 | 5/13/2026 |
| 2026年1月12日-preview | 561 | 5/12/2026 |
| 2026年1月11日-preview | 701 | 5/6/2026 |
| 2026年1月10日-preview | 1,031 | 4/29/2026 |
| 2026年1月9日-preview | 701 | 4/17/2026 |
| 2026年1月8日-preview | 382 | 4/13/2026 |
| 2026年1月7日-preview | 842 | 3/31/2026 |
| 2026年1月6日-preview | 494 | 3/28/2026 |
| 2026025 | 194 | 6/30/2026 |
| 2026024 | 253 | 6/27/2026 |
| 2026023 | 1,989 | 5/15/2026 |
| 2026022 | 916 | 4/29/2026 |
| 2026021 | 489 | 4/17/2026 |
| 2025年1月18日 | 195 | 6/30/2026 |