Compze.Teventive.MemoryImageStateStore
0.2.0-alpha
dotnet add package Compze.Teventive.MemoryImageStateStore --version 0.2.0-alpha
NuGet\Install-Package Compze.Teventive.MemoryImageStateStore -Version 0.2.0-alpha
<PackageReference Include="Compze.Teventive.MemoryImageStateStore" Version="0.2.0-alpha" />
<PackageVersion Include="Compze.Teventive.MemoryImageStateStore" Version="0.2.0-alpha" />
<PackageReference Include="Compze.Teventive.MemoryImageStateStore" />
paket add Compze.Teventive.MemoryImageStateStore --version 0.2.0-alpha
#r "nuget: Compze.Teventive.MemoryImageStateStore, 0.2.0-alpha"
#:package Compze.Teventive.MemoryImageStateStore@0.2.0-alpha
#addin nuget:?package=Compze.Teventive.MemoryImageStateStore&version=0.2.0-alpha&prerelease
#tool nuget:?package=Compze.Teventive.MemoryImageStateStore&version=0.2.0-alpha&prerelease
Compze.Teventive.MemoryImageStateStore
The memory image state store: a memory image of Compze taggregates. Every taggregate is held in memory for the container's life, and rebuilt at the store's start from a snapshot of each, which its storage keeps: it keeps taggregates as their state, not their history.
What is Compze?
Compze is a .NET framework for building expressive domains through Teventive programming and Typermedia APIs. Learn more
What's in this package?
- The memory image state store — composed with
MemoryImageStateStore(...), it keeps the taggregate classes declared for it in memory, and in JSON files, or in a database's tables, if they are declared. - JSON files —
StoredInJsonFiles(...): a file for each taggregate, in a folder for each class, written with the consumer'sJsonSerializerOptions, and a unit of work's files written all or none. Compze.Teventive.MemoryImageStateStore.MemoryPack adds a cache to start from, so a start reads only the files changed since.ITaggregateJsonFilesgives the path of each taggregate's file, and the taggregate each file is the file of. For specifications,OnAFileSystemInMemory(), in theTestingnamespace, puts the files on a file system in memory, read and changed throughIFileSystemInMemory, with no disk I/O. - A database's tables —
StoredInTheDomainDatabase(...): a row for each taggregate in the domain database, holding its class by a name declared for it and its snapshot as the consumer'sJsonSerializerOptionswrite it, beside the store's SQL layer from Compze.Teventive.MemoryImageStateStore.Sqlite, .MicrosoftSql, .PostgreSql or .MySql. A unit of work commits as one database transaction, with whatever else it writes to the database, such as an exactly-once endpoint's inbox and outbox. Several memory images, in other processes or other containers, share the tables: a get for update takes the taggregate's lock in the database and its state from its row when another memory image committed it since, and a memory image catches up with the others at each unit of work's first change of the store, or, declared, within about 50 ms of their commits on the same machine.IMemoryImageStateStore.ChangesCommittedByOtherMemoryImagestells what it found. - Reloads and rewrites —
IMemoryImageStateStore.LoadFromStorage()loads the files again and reports which taggregates another program added, changed or removed, comparing only the files changed since the store last read or wrote them, so snapshot types need no equality.IMemoryImageStateStore.WriteAllToStorage()writes every file anew, as one commit, after a change to the snapshot types or to the serializer's options. - Units of work with private copies — each unit of work changes its own copy of a taggregate, holding its lock until it completes, and the copy becomes the committed instance when it commits.
- Synchronous dispatch — the tevents a unit of work's taggregates publish are dispatched as each publish cascade ends, once the taggregate's invariants hold, so participation handlers run inside the domain call and the unit of work's transaction.
- Indexes defined by state —
ITaggregateIndex<TTaggregate, TKey>files taggregates under keys their state gives, in no particular order, and reads its own unit of work's changes. A store has one index for each pair of taggregate class and key type, and a key function reads only the taggregate's own state. - Every taggregate of a class —
ITaggregateStoreBulkReader.ReferencesToAll<TTaggregate>(), in no particular order. - What holding everything costs — its memory is the whole data set, and it loads every taggregate at its first use, on that use's thread: call
LoadFromStorage()at the application's start to choose when. A failure after a commit's journal is written stops the process (Environment.FailFast), and the next start finishes the commit. The files are written, not flushed to the disk. Its waits, for a taggregate's lock and between a load and the units of work, give up after 30 seconds.
The interfaces it implements, ITaggregateStoreReader, ITaggregateStoreBulkReader and ITaggregateStoreUpdater, are in Compze.Teventive.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Compze.Abstractions (>= 0.4.1-alpha)
- Compze.Contracts (>= 0.7.2)
- Compze.DependencyInjection (>= 0.10.0-alpha)
- Compze.Internals.SystemCE (>= 0.10.0-internal)
- Compze.Tessaging.Abstractions (>= 0.6.0-alpha)
- Compze.Teventive (>= 0.7.1-alpha)
- Compze.Threading (>= 0.13.0-alpha)
- Compze.Threading.Interprocess (>= 0.7.1-alpha)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Compze.Teventive.MemoryImageStateStore:
| Package | Downloads |
|---|---|
|
Compze.Teventive.MemoryImageStateStore.MemoryPack
A MemoryPack cache for Compze.Teventive.MemoryImageStateStore's JSON files, so a memory image state store kept in files starts from the cache and reads only the files changed since. |
|
|
Compze.Teventive.MemoryImageStateStore.MySql
The MySQL tables of Compze's memory image state store: MySqlMemoryImageStateStoreSqlLayer(), for a memory image state store kept in the tables of a MySQL domain database, which several memory images, in other processes or other containers, share. |
|
|
Compze.Teventive.MemoryImageStateStore.PostgreSql
The PostgreSQL tables of Compze's memory image state store: PgSqlMemoryImageStateStoreSqlLayer(), for a memory image state store kept in the tables of a PostgreSQL domain database, which several memory images, in other processes or other containers, share. |
|
|
Compze.Teventive.MemoryImageStateStore.MicrosoftSql
The SQL Server tables of Compze's memory image state store: MsSqlMemoryImageStateStoreSqlLayer(), for a memory image state store kept in the tables of a SQL Server domain database, which several memory images, in other processes or other containers, share. |
|
|
Compze.Teventive.MemoryImageStateStore.Sqlite
The SQLite tables of Compze's memory image state store: SqliteMemoryImageStateStoreSqlLayer(), for a memory image state store kept in the tables of a SQLite domain database, which several memory images, in other processes or other containers, share. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.2.0-alpha | 0 | 11/25/2026 |
| 0.1.0-alpha | 80 | 11/19/2026 |
- **Documentation: files that accept non-atomic commits with a database commit after the database, whichever the database,** as `AcceptingNonAtomicCommitsWithADatabase()` now says. Before the versions of Compze.Sql.Sqlite and Compze.Sql.MySql whose connections commit as their transaction's decision, they committed before a SQLite or MySQL connection. And when the database's commit is in doubt, as when its connection breaks while it commits, the files don't commit, though the database may have, as `AcceptingNonAtomicCommitsWithADatabase()` now says too.
- **`StoredInTheDomainDatabase(options, rows => rows.ClassNamed<TTaggregate>(name))` keeps the store in tables of the domain database,** beside the store's SQL layer for it, from one of the packages Compze.Teventive.MemoryImageStateStore.Sqlite, .MicrosoftSql, .PostgreSql and .MySql: `SqliteMemoryImageStateStoreSqlLayer()` and its siblings, declared after the domain database. A row for each taggregate holds its class by the name declared for it, which renaming or moving the class leaves readable, and exactly what the consumer's `JsonSerializerOptions` make of its snapshot. A unit of work commits as one database transaction, with whatever else it writes to the domain database, such as an exactly-once endpoint's inbox and outbox. Each class the store keeps is named, and no two share a name: asserted where the store is composed.
- **Several memory images share the tables:** other processes, and other containers of one process. Getting a taggregate for update, or adding one, takes the taggregate's lock in the database, and takes its state from its row when another memory image has committed it since, so no update is lost. A memory image catches up with what the others committed at each unit of work's first get for update or add; reads outside a unit of work read what it last caught up with, with no round trip to the database.
- **Commits are numbered in the order they commit,** from a counter in the database that each commit takes at the very end of its prepare and holds until it commits, so catching up by number misses no commit. Commits that write the store's rows commit one at a time while they write their rows.
- **`rows.CatchingUpAsOtherMemoryImagesOnThisMachineCommit()`** has a memory image catch up within about 50 ms of another's commit on the same machine, woken by an interprocess signal, and query the database only when one has committed.
- **`IMemoryImageStateStore.ChangesCommittedByOtherMemoryImages`,** an `IObservable<ChangesFoundInStorage>`, tells what a memory image found that others committed: in the order found, one batch at a time, never on the thread that found them.
- `LoadFromStorage()` reports a taggregate changed when its row was written by another commit than the one the store holds it as, and `WriteAllToStorage()` writes every row anew as one commit, which takes the counter first, so that no other memory image commits meanwhile.
- **Requires newer minor versions of other Compze packages:** Compze.Internals.SystemCE 0.10.0-internal (was 0.9.0-internal), Compze.Threading 0.13.0-alpha (was 0.12.0-alpha). Upgrading to this version upgrades each package listed here too, so their changelogs apply to this upgrade as well.