logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class KeyValueStructuredStore

    IStructuredStore implementation backed by an IKeyValueStore.

    Inheritance
    object
    KeyValueStructuredStore
    Implements
    IStructuredStore
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.StructuredPersistence.Infrastructure.KeyValue
    Assembly: Serenity.StructuredPersistence.KeyValue.dll
    Syntax
    public class KeyValueStructuredStore : IStructuredStore
    Remarks

    Shards one key-value key per distinct value of the constructor-injected partition field ("{tableName}/{partitionValue}"), holding every raw record for that partition, serialized via the injected ISerializer<T>. Every operation resolves its partition either from the record being written or from a REQUIRED Equal filter on the partition field — this store cannot answer a cross-partition query. StructuredQueryEngine performs every filter/sort/distinct/trim computation in memory after loading a partition, so query semantics stay identical across every IStructuredStore backend.

    Reliability contract: a failed or corrupt load logs a warning and treats the partition as empty; a failed save logs a warning and is swallowed — persistence problems never crash gameplay. Write operations are serialized per partition so concurrent writers cannot lose each other's updates.

    Constructors

    KeyValueStructuredStore(IKeyValueStore, ISerializer<StructuredRecord[]>, string, ILogService)

    Initializes a new instance of the KeyValueStructuredStore class.

    Declaration
    public KeyValueStructuredStore(IKeyValueStore keyValueStore, ISerializer<StructuredRecord[]> serializer, string partitionField, ILogService logService)
    Parameters
    Type Name Description
    IKeyValueStore keyValueStore

    Backing key-value store used for persistence.

    ISerializer<StructuredRecord[]> serializer

    Serializer used to encode/decode a partition's raw record list.

    string partitionField

    The field every record is sharded by. Every query/count/delete/trim operation requires an Equal filter on this field.

    ILogService logService

    Logging service used to report load/save failures. May be null.

    Properties

    Namespace

    Declaration
    public string Namespace { get; }
    Property Value
    Type Description
    string

    Methods

    CountAsync(StoreTable, IReadOnlyList<FieldFilter>, IReadOnlyList<string>, CancellationToken)

    Declaration
    public Task<long> CountAsync(StoreTable table, IReadOnlyList<FieldFilter> filters, IReadOnlyList<string> distinctBy, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StoreTable table
    IReadOnlyList<FieldFilter> filters
    IReadOnlyList<string> distinctBy
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<long>

    DeleteByQueryAsync(StoreTable, IReadOnlyList<FieldFilter>, CancellationToken)

    Declaration
    public Task DeleteByQueryAsync(StoreTable table, IReadOnlyList<FieldFilter> filters, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StoreTable table
    IReadOnlyList<FieldFilter> filters
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    EnsureSchemaAsync(StructuredTableSchema, CancellationToken)

    Declaration
    public Task EnsureSchemaAsync(StructuredTableSchema schema, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StructuredTableSchema schema
    CancellationToken cancellationToken
    Returns
    Type Description
    Task
    Remarks

    The key-value backend has no schema to manage; this is a no-op.

    HealthCheckAsync(CancellationToken)

    Declaration
    public Task<bool> HealthCheckAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<bool>

    InsertAsync(StoreTable, StructuredRecord, StructuredTrim, CancellationToken)

    Declaration
    public Task InsertAsync(StoreTable table, StructuredRecord record, StructuredTrim trim, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StoreTable table
    StructuredRecord record
    StructuredTrim trim
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    QueryAsync(StoreTable, StructuredQuery, CancellationToken)

    Declaration
    public Task<IReadOnlyList<StructuredRecord>> QueryAsync(StoreTable table, StructuredQuery query, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StoreTable table
    StructuredQuery query
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<IReadOnlyList<StructuredRecord>>

    TrimBeyondAsync(StoreTable, IReadOnlyList<FieldFilter>, IReadOnlyList<OrderField>, int, CancellationToken)

    Declaration
    public Task TrimBeyondAsync(StoreTable table, IReadOnlyList<FieldFilter> scopeFilters, IReadOnlyList<OrderField> ordering, int keepCount, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StoreTable table
    IReadOnlyList<FieldFilter> scopeFilters
    IReadOnlyList<OrderField> ordering
    int keepCount
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    UpsertIfBetterAsync(StoreTable, StructuredRecord, IReadOnlyList<string>, string, StructuredSortDirection, StructuredTrim, CancellationToken)

    Declaration
    public Task UpsertIfBetterAsync(StoreTable table, StructuredRecord record, IReadOnlyList<string> keyFields, string comparisonField, StructuredSortDirection betterDirection, StructuredTrim trim, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    StoreTable table
    StructuredRecord record
    IReadOnlyList<string> keyFields
    string comparisonField
    StructuredSortDirection betterDirection
    StructuredTrim trim
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    Implements

    IStructuredStore
    In this article
    © 2026 Serenity. All Rights Reserved