Path: redb-route/redb.Route.Cache/CacheFlights.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Cache/CacheFlights.cs
----
using System.Collections.Concurrent;
namespace redb.Route.Cache;
///
/// The computations in progress, one per store key: while one exchange computes a missing entry, the
/// others arriving for the same key wait for its result instead of each running the inner steps.
/// One instance per context, with a map per provider, so every cache node that shares a store shares
/// its flights as well. Other processes (and other contexts) compute on their own.
///
internal sealed class CacheFlights
{
private readonly ConcurrentDictionary> _memory = new(StringComparer.Ordinal);
private readonly ConcurrentDictionary> _distributed = new(StringComparer.Ordinal);
/// The flights of the store that serves in this context.
public ConcurrentDictionary> For(CacheProvider provider)
=> provider == CacheProvider.Distributed ? _distributed : _memory;
}