logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityPlayerPrefsKeyValueStore

    Unity implementation of IKeyValueStore using PlayerPrefs for persistence.

    Inheritance
    object
    UnityPlayerPrefsKeyValueStore
    Implements
    IKeyValueStore
    IKeyedStore
    IPersistenceStore
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.PlayerPrefsPersistence.Infrastructure.Stores
    Assembly: Serenity.UnityPlayerPrefsPersistence.Infrastructure.dll
    Syntax
    public class UnityPlayerPrefsKeyValueStore : IKeyValueStore, IKeyedStore, IPersistenceStore
    Remarks

    Stores binary data as Base64-encoded strings in PlayerPrefs. Suitable for lightweight key-value persistence where stream-based I/O is not desired. PlayerPrefs has platform-specific size limits — not suitable for large blobs.

    Constructors

    UnityPlayerPrefsKeyValueStore(string, string)

    Initializes a new instance of the UnityPlayerPrefsKeyValueStore class.

    Declaration
    public UnityPlayerPrefsKeyValueStore(string keyPrefix = "Serenity_", string @namespace = "playerprefs")
    Parameters
    Type Name Description
    string keyPrefix

    Optional prefix prepended to every PlayerPrefs key to avoid collisions. Defaults to "Serenity_".

    string namespace

    Logical namespace for diagnostics/telemetry. Defaults to "playerprefs".

    Properties

    Namespace

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

    Methods

    DeleteAsync(string, CancellationToken)

    Declaration
    public Task DeleteAsync(string key, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    string key
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    ExistsAsync(string, CancellationToken)

    Declaration
    public Task<bool> ExistsAsync(string key, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    string key
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<bool>

    GetAsync(string, CancellationToken)

    Declaration
    public Task<ReadOnlyMemory<byte>?> GetAsync(string key, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    string key
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<ReadOnlyMemory<byte>?>

    HealthCheckAsync(CancellationToken)

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

    SetAsync(string, ReadOnlyMemory<byte>, CancellationToken)

    Declaration
    public Task SetAsync(string key, ReadOnlyMemory<byte> value, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    string key
    ReadOnlyMemory<byte> value
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    Implements

    IKeyValueStore
    IKeyedStore
    IPersistenceStore
    In this article
    © 2026 Serenity. All Rights Reserved