InMemoryPropertyStore

class InMemoryPropertyStore(initialProperties: Map<String, Property<*>> = emptyMap()) : PropertyStore(source)

In-memory implementation of PropertyStore.

This store keeps feature properties in a mutable map backed by process memory. It is intended for tests, local development, or lightweight runtime configurations where persistence across application restarts is not required.

Concurrency and thread safety

All operations on the underlying map are guarded by a Mutex and executed via the withReentrantLock utility, which provides coroutine-friendly, reentrant mutual exclusion. This ensures that:

  • concurrent readers and writers are serialized, preventing data races; and

  • a coroutine that already holds the lock can safely call other methods on this store without deadlocking.

Despite being thread-safe within a single process, this implementation does not provide any cross-process or distributed consistency guarantees.

Constructors

Link copied to clipboard
constructor(initialProperties: Map<String, Property<*>> = emptyMap())
constructor(config: FF4kConfiguration)

Functions

Link copied to clipboard
open suspend override fun clear()

Removes all properties from the store.

Link copied to clipboard
open suspend operator override fun contains(propertyId: String): Boolean

Checks if a property with the given id exists in the store.

Link copied to clipboard
suspend fun PropertyStore.count(): Int

Returns the number of properties in the store.

Link copied to clipboard
suspend fun <T> PropertyStore.createOrUpdateProperty(property: Property<T>)

Creates a new property or updates it if it already exists (upsert operation).

Link copied to clipboard
open suspend operator override fun <T> get(propertyId: String): Property<T>?

Retrieves a property by id.

Link copied to clipboard
open suspend override fun getAll(): Map<String, Property<*>>

Retrieves all properties in the store.

Link copied to clipboard
open suspend override fun <T> getOrDefault(propertyId: String, defaultValue: Property<T>): Property<T>

Retrieves a property by id, or returns a default if not found.

Link copied to clipboard

Retrieves a property by name, throwing an exception if not found.

Link copied to clipboard
suspend fun <T> PropertyStore.getPropertyValue(name: String): T?

Retrieves a property's value directly, without the Property wrapper.

Link copied to clipboard
suspend fun <T> PropertyStore.getPropertyValueOrDefault(name: String, default: T): T

Retrieves a property's value, or returns a default if not found.

Link copied to clipboard
open suspend override fun isEmpty(): Boolean

Checks whether the store is empty.

Link copied to clipboard
open suspend override fun listPropertyIds(): Set<String>

Lists all property ids in the store.

Link copied to clipboard
open suspend operator override fun minusAssign(propertyId: String)

Removes a property from the store by id.

Link copied to clipboard
open suspend operator override fun <T> plusAssign(property: Property<T>)

Adds a new property to the store.

Link copied to clipboard
open suspend override fun <T> updateProperty(property: Property<T>)

Updates an existing property in the store.

open suspend override fun <T> updateProperty(name: String, transform: (Property<T>) -> Property<T>)

Atomically updates a property using a transformation function.