namespace StellaOps.Messaging.Abstractions;
///
/// Transport-agnostic distributed cache interface.
///
/// The key type.
/// The value type.
public interface IDistributedCache
{
///
/// Gets the provider name for diagnostics (e.g., "valkey", "postgres").
///
string ProviderName { get; }
///
/// Gets a value from the cache.
///
/// The cache key.
/// Cancellation token.
/// The cache result.
ValueTask> GetAsync(TKey key, CancellationToken cancellationToken = default);
///
/// Sets a value in the cache.
///
/// The cache key.
/// The value to cache.
/// Optional cache entry options.
/// Cancellation token.
ValueTask SetAsync(TKey key, TValue value, CacheEntryOptions? options = null, CancellationToken cancellationToken = default);
///
/// Removes a value from the cache.
///
/// The cache key.
/// Cancellation token.
/// True if the key existed and was removed.
ValueTask InvalidateAsync(TKey key, CancellationToken cancellationToken = default);
///
/// Removes values matching a pattern from the cache.
///
/// The key pattern (supports wildcards).
/// Cancellation token.
/// The number of keys invalidated.
ValueTask InvalidateByPatternAsync(string pattern, CancellationToken cancellationToken = default);
///
/// Gets or sets a value in the cache, using a factory function if the value is not present.
///
/// The cache key.
/// Factory function to create the value if not cached.
/// Optional cache entry options.
/// Cancellation token.
/// The cached or newly created value.
ValueTask GetOrSetAsync(
TKey key,
Func> factory,
CacheEntryOptions? options = null,
CancellationToken cancellationToken = default);
}
///
/// Simple string-keyed distributed cache interface.
///
/// The value type.
public interface IDistributedCache : IDistributedCache
{
}