XiHan.Framework.Persistence.InMemory
5.0.0-preview.1
Prefix Reserved
This is a prerelease version of XiHan.Framework.Persistence.InMemory.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package XiHan.Framework.Persistence.InMemory --version 5.0.0-preview.1
NuGet\Install-Package XiHan.Framework.Persistence.InMemory -Version 5.0.0-preview.1
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.Persistence.InMemory" Version="5.0.0-preview.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XiHan.Framework.Persistence.InMemory" Version="5.0.0-preview.1" />
<PackageReference Include="XiHan.Framework.Persistence.InMemory" />
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.Persistence.InMemory --version 5.0.0-preview.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: XiHan.Framework.Persistence.InMemory, 5.0.0-preview.1"
#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.Persistence.InMemory@5.0.0-preview.1
#: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.Persistence.InMemory&version=5.0.0-preview.1&prerelease
#tool nuget:?package=XiHan.Framework.Persistence.InMemory&version=5.0.0-preview.1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
XiHan.Framework.Persistence.InMemory
内存持久化。清单 role: default、stability: preview:没有显式 Provider 时被选中,只用于开发、原型与测试。
语义
- 每种实体一张表,容量上限
XiHan:Persistence:InMemory:MaxEntitiesPerType(默认 100000),超出返回PERSISTENCE_UNAVAILABLE_002。 - 工作单元读己之写:新增、更新、删除先进覆盖层;回滚丢弃。
- 没有数据库事务,
HasTransaction与关系型 Provider 同义(ADR-0109):可写工作单元里仓储第一次接受写入调用(单条,或集合非空的批量,不论结果)起为真——覆盖层从此可能有未提交、随回滚丢弃的变更;提交(含提交时校验失败)与回滚后为假,只读工作单元恒为假。 - 只读工作单元(只读操作或
UnitOfWorkOptions(IsReadOnly: true))的写入在进覆盖层之前就返回PERSISTENCE_UNEXPECTED_001(批量逐项都是它),并把工作单元记为失败,提交回滚并返回同一错误。 - 软删除、创建与修改时间、租户写入与过滤、并发戳刷新按
PersistenceConventions执行。 - 读写都复制:查找、
FindManyAsync、查询交出的是副本,写入存的是调用方实例的副本(InMemoryTable.Find/Snapshot同样交出副本)。在读出的实例上的修改不经仓储写回就碰不到存储,回滚后不留痕迹。副本是字段逐一的浅复制:标量与协议字段互不影响,集合、嵌套对象等引用类型字段(含聚合的领域事件缓冲)仍与副本共享,不在隔离范围内。 - 提交时校验:覆盖层记下每个写过的标识首次读到的已提交状态,提交按建表先后给涉及的表依次加锁,在全部锁内逐表校验——新增的标识已被别的工作单元提交返回
PERSISTENCE_CONFLICT_002;更新或删除的行已被删除、带并发戳的行戳已变返回PERSISTENCE_CONFLICT_001;之后是容量——全部通过才逐表应用,跨表原子,失败时任何一张表都不改。 - 更新沿用当前行的创建时间、租户与删除标记,软删除在当前行的副本上打标(调用方实例上的其他改动不写入),删除标记再同步回调用方实例。
- 命名连接(ADR-0084)不支持:内存实现没有连接。实体以
AddRepository<TEntity, TKey>(connection)登记到命名连接在装配时、UnitOfWorkOptions(Connection: …)在BeginAsync抛出携带PERSISTENCE_UNAVAILABLE_008的FrameworkException,不静默落在唯一的存储上。 - 运行时数据源(ADR-0078)不支持:内存实现没有数据库。注册表
DataSourceRegistry照样登记,取用与测试连接返回PERSISTENCE_UNAVAILABLE_008。 - 实体目录(ADR-0078):没有表,表名取实体类型名,列取有公开 setter 的非集合属性、列名即属性名(这是它的存储形态),主键是
Id。库结构读取不支持(PERSISTENCE_UNAVAILABLE_008)。 - 健康项
persistence.inmemory.capacity(存储自己实现,同步计算):任一实体的表达到MaxEntitiesPerType即 Degraded(PERSISTENCE_UNAVAILABLE_002,entity是按序数顺序的第一个满表),否则 Ready。
依赖方向
依赖 XiHan.Framework.Persistence.Abstractions。
状态
P2:可用,通过 Persistence.Conformance 套件。
| Product | Versions 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.
-
net10.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Diagnostics.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Options (>= 10.0.14)
- System.Threading.RateLimiting (>= 10.0.14)
- XiHan.Framework.Persistence.Abstractions (>= 5.0.0-preview.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on XiHan.Framework.Persistence.InMemory:
| Package | Downloads |
|---|---|
|
XiHan.Framework.Profiles.Standard
曦寒框架 Standard 组合包 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.0.0-preview.2 | 52 | 11/6/2026 |
| 5.0.0-preview.1 | 49 | 11/4/2026 |