7.5 KiB
7.5 KiB
Changelog
All notable changes to cultcache-rs are recorded here, following
Keep a Changelog. Earlier releases are recorded
only in git history.
Unreleased
Breaking
- A single-file store written as
cultcache.store.v3is read and written: a store the C# runtime marked v3 (it holds a record with an element id: an owned list element with a[CultElementId]member) keeps its header here, and is carried through every rewrite with its ids; this runtime never drops the mark. A runtime from before this change refuses a v3 store by name. Rolling back to an older release after a store has been written as v3 is one-way: there is no carry-back, so restore from a copy taken before upgrading. - A write over a file the reader refuses (a zero-byte file, a truncated store, a stamp this runtime does not read) refuses with
CultCacheStoreUnreadableand leaves the file as it is. A whole-store write used to replace such a file. This reverses 0.3.1, wherepush_allreplaced a file with no readable stamp (healing it); the stamp rule now has one owner, the reader every write asks under the lock, and it accepts v1 and v3 (0.3.1 refused v3). #[cultcache(index)]means unique, as in C#RefuseIndexSharing: within one type and one alias no two records hold one non-blank value. A put, batch, push or load that would make two records hold a value is refused, naming both keys and the alias, and a store that already holds a duplicate does not open. A grouping index is no longer expressible; a consumer that relied on shared values must drop theindexand look up by another way.boolindex and lookup text rendersTrue/False, as C# does, where it renderedtrue/false.DatabaseEntry::UNIQUE_INDEXESreplacescult_indexesas the one index declaration and changes type (its members are the unique aliases); a hand implementation overridingcult_indexesno longer compiles.register_entry_typeover a type that already holds records re-judges them under the new declaration (unique indexes and the global rule) and refuses, changing nothing, when they violate it. A declaration with an index also refuses when a held record cannot be decoded as the new type; a declaration without one does not read the records, so it does not.- A single-file store holds one record per key. The v1 and legacy readers refuse a store with two records under one key (
CultCacheStoreUnreadable, the recordUndecodable): the store does not open, and a write over it refuses and leaves the file. A consumer that holds such a file must repair it with the runtime that wrote it before opening it here. - Every single-file writer (
push,push_all,insert_entry_if_absent, the compare-exchange and snapshot-append family, and the cache's puts and batches) refuses to put a second type under a key the store holds, withSchemaConflictErrornaming the key and both types, writing nothing. Retyping a key is a delete, then an add (one batch may hold both). A write owns the held record when its schema id equals the id the held record is stored under, as C#WrittenOwnsasks; a type renamed under a stable id therefore replaces its own record, and a write of another type name under another id is refused (pushof the same type name under another id still replaces the record, as before;compare_and_swap_entry, and apush_allbatch holding one type under two ids, refuse it). Registered types here declare no compatible ids, so equality is the whole test. Writers used to leave two records under the key. compare_and_swap_entryover a single file refuses an in-place retype (expectedA/k, replacementB/kunder another schema id) with the sameSchemaConflictError, ascompare_exchangedoes, where it used to retype the record and returntrue. A lost race still returnsfalsefirst.- A cache holds one record per key.
put,put_envelope,put_raw_envelopeand a batch of a second type under a key the cache holds, or a key a store carries foreign, are refused withSchemaConflictErroreven with no store (a memory-only cache used to hold both), whatever schema id the envelope claims: another registered type's record is never owned.put_envelope,put_raw_envelope,put_prepared_batchandload_soaalso refuse, at any key, an envelope whose schema id names another type registered in this cache (the id a pull would resolve the record by). An id this cache does not register is trusted as the envelope claims it: at a key this cache does not hold, the single-file store decides ownership by that id, so such an envelope can replace another writer's record stored under it, and a reader registering the type the id names serves the record as that type. Store-level writers called directly (push,insert_entry_if_absent, compare-and-swap) still trust the claimed id. A refused write or pull changes nothing. Two stores holding one key refuse the pull, naming the key and both types, and so does one store holding two records at a key that resolve to one type. A store holding a record no registered type claims now loads (it used to refuse with "No schema is registered for persisted entry type") and the record is carried, throughput_prepared_batchtoo, which lays foreign records back byte for byte;deleteat a foreign key is refused.load_soarefuses a second type at a key or a record at a foreign key, and still refuses an unregistered type. The redb stores still key by(type, key), and their own writers (push,insert_entry_if_absent, compare-and-swap) still put a second type at a held key: a cache now refuses to pull such a redb store withSchemaConflictError, where it used to load both records. - A write of the same type under a held key replaces the record by key, and in one
push_allthe last given of several entries under a key and a schema id is the record, whatever their type names. The redb stores are unchanged and still key by type and key.
Added
CultCache::foreign_records()andForeignRecord { key, schema_id, schema_name, stored_at }: the records the last pull found that no registered type claims, sorted by key.- Lookups, matching the C#
GetByName,GetByIndexandGetGlobal.#[cultcache(name)]and#[cultcache(index)]/#[cultcache(index = "alias")]onDatabaseEntryfields and#[cultcache(global)]on the struct giveCultCache::get_by_name,get_by_indexandget_global. An empty name and a blank index value are not found; records of one type sharing a name find the one with the smallest key (an index value is unique, below). A second record of a global type under another key is refused on every write path and on load withCultCacheSecondGlobal. Twonamemembers, or two members with one index alias, are refused at compile time. A member's text comes fromCultLookupValue(String,Optionof one, integers,bool,char). SchemaConflictError, the typed refusal of a write the catalog cannot describe: records of different types under one schema id, or an arrived schema and a registered one that share an id and disagree on the schema name. A whole-store write (push_all) refuses with it, names the schema id, the names involved and a record key, writes nothing and leaves the file as it is. A caller tells it apart witherror.downcast_ref::<SchemaConflictError>().
[0.3.1]
Fixed
push_allreads the store's header under the lock and refuses a format this runtime does not read, withCultCacheStoreUnreadableUnsupportedFormat, leaving the file as it was. A file with no readable stamp is still replaced, so a whole write heals it.