XiHan.Framework.Caching.Abstractions 5.0.0-preview.2

Prefix Reserved
This is a prerelease version of XiHan.Framework.Caching.Abstractions.
dotnet add package XiHan.Framework.Caching.Abstractions --version 5.0.0-preview.2
                    
NuGet\Install-Package XiHan.Framework.Caching.Abstractions -Version 5.0.0-preview.2
                    
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="XiHan.Framework.Caching.Abstractions" Version="5.0.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XiHan.Framework.Caching.Abstractions" Version="5.0.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="XiHan.Framework.Caching.Abstractions" />
                    
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 XiHan.Framework.Caching.Abstractions --version 5.0.0-preview.2
                    
#r "nuget: XiHan.Framework.Caching.Abstractions, 5.0.0-preview.2"
                    
#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 XiHan.Framework.Caching.Abstractions@5.0.0-preview.2
                    
#: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=XiHan.Framework.Caching.Abstractions&version=5.0.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=XiHan.Framework.Caching.Abstractions&version=5.0.0-preview.2&prerelease
                    
Install as a Cake Tool

XiHan.Framework.Caching.Abstractions

关于

XiHan.Framework.Caching.Abstractions 定义缓存的契约:字节存储 ICacheStore、类型化缓存 ICache / ISharedCache、序列化器、分布式锁,以及按幂等键去重的 Idempotency 中间件。不包含存储实现。

主要特性

  • 进程内缓存与跨进程共享缓存两套门面,支持批量读写与 GetOrCreateAsync
  • 绝对或滑动过期
  • 基于存储的分布式租约锁
  • IDistributedCache 适配与操作调用的幂等去重

如何使用

安装

dotnet add package XiHan.Framework.Caching.Abstractions --prerelease

使用

通常由实现包带入;写业务代码或自定义缓存提供程序时才直接引用。实现包有 Caching.InMemory、Caching.Redis、Caching.Remote、Caching.Hybrid。业务代码里这样用:

var cache = context.Services.GetRequiredService<ISharedCache>();
var profile = await cache.GetOrCreateAsync(
    new CacheKey($"profile:{id}"),
    ct => LoadAsync(id, ct),
    CacheEntryOptions.Expires(TimeSpan.FromMinutes(5)),
    ct);

存储不可达时抛出携带 CACHING_UNAVAILABLE_001 的 FrameworkException,不会伪装成未命中。

主要类型

此库提供的主要类型:

  • ICache、ISharedCache:类型化缓存门面
  • ICacheStore:字节级存储,提供程序实现它
  • CacheKey、CacheEntryOptions:键与过期选项
  • IDistributedLock、LockHandle:分布式锁
  • ICacheSerializer、JsonCacheSerializer:共享缓存的值序列化
  • IdempotencyMiddleware:按幂等键去重

更多文档

相关包

反馈与贡献

XiHan.Framework.Caching.Abstractions 以 MIT 许可证 开源。欢迎到 GitHub 仓库 提交问题和贡献。

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 (7)

Showing the top 5 NuGet packages that depend on XiHan.Framework.Caching.Abstractions:

Package Downloads
XiHan.Framework.Persistence.Abstractions

曦寒框架持久化抽象包

XiHan.Framework.Profiles.Standard

曦寒框架 Standard 组合包

XiHan.Framework.Caching.Remote

曦寒框架缓存的远程插件提供程序

XiHan.Framework.Caching.Redis

曦寒框架缓存的 Redis 提供程序

XiHan.Framework.Caching.InMemory

曦寒框架缓存的内存默认实现

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.0.0-preview.2 0 11/6/2026
5.0.0-preview.1 85 11/4/2026