Ferrous Music Store API

All Types / MusicStore.Api.Services

class InventoryCache

public sealed class InventoryCache

Data-owning inventory cache backed by Mutex<T>. Eliminates raw lock blocks — it is impossible to read or mutate the dictionary without holding the guard.

Methods

public void SetStock(AlbumId albumId, int count)

Updates the cached stock level for albumId.

public Option<int> GetStock(AlbumId albumId)

Reads the cached stock level for albumId as an Option<T>.

public bool TryReserve(AlbumId albumId, int quantity)

Atomically reserves quantity units if sufficient stock is cached.