namespace StellaOps.Provcache;
///
/// High-level service interface for Provcache operations.
/// Orchestrates cache store and repository with metrics and invalidation logic.
///
public interface IProvcacheService
{
///
/// Gets a cached decision by VeriKey.
///
/// The cache key.
/// If true, skip cache and force re-evaluation.
/// Cancellation token.
/// The cache result with decision if found.
Task GetAsync(
string veriKey,
bool bypassCache = false,
CancellationToken cancellationToken = default);
///
/// Stores a decision in the cache.
///
/// The cache entry to store.
/// Cancellation token.
/// True if the entry was stored successfully.
Task SetAsync(ProvcacheEntry entry, CancellationToken cancellationToken = default);
///
/// Gets or computes a decision using a factory function for cache misses.
///
/// The cache key.
/// Factory function to create the entry on cache miss.
/// If true, skip cache and force re-computation.
/// Cancellation token.
/// The cached or newly computed entry.
Task GetOrComputeAsync(
string veriKey,
Func> factory,
bool bypassCache = false,
CancellationToken cancellationToken = default);
///
/// Invalidates a cache entry by VeriKey.
///
/// The cache key.
/// Reason for invalidation (for audit log).
/// Cancellation token.
/// True if the entry existed and was invalidated.
Task InvalidateAsync(
string veriKey,
string? reason = null,
CancellationToken cancellationToken = default);
///
/// Invalidates entries by invalidation criteria.
///
/// The invalidation request.
/// Cancellation token.
/// Invalidation result with count of affected entries.
Task InvalidateByAsync(
InvalidationRequest request,
CancellationToken cancellationToken = default);
///
/// Gets cache metrics for monitoring.
///
/// Cancellation token.
/// Cache metrics.
Task GetMetricsAsync(CancellationToken cancellationToken = default);
///
/// Prunes expired entries from the cache.
///
/// Cancellation token.
/// Number of entries pruned.
Task PruneExpiredAsync(CancellationToken cancellationToken = default);
}