Path: redb/redb.Core/Models/Contracts/ISchemeCacheProvider.cs Snapshot: redb, 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 Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/Models/Contracts/ISchemeCacheProvider.cs ---- using System; using System.Threading; using System.Threading.Tasks; using redb.Core.Caching; namespace redb.Core.Models.Contracts { /// /// Extension of ISchemeSyncProvider with metadata cache management methods /// Adds capabilities for hot switching, invalidation and cache warmup /// public interface ISchemeCacheProvider { // ===== CACHE STATE MANAGEMENT ===== /// /// Enable/disable metadata caching on the fly (hot toggle) /// When disabled, automatically clears all cache /// /// true - enable cache, false - disable void SetCacheEnabled(bool enabled); /// /// Check if caching is enabled /// bool IsCacheEnabled { get; } // ===== CACHE INVALIDATION ===== /// /// Complete clearing of all metadata caches /// Resets statistics to zero /// void InvalidateCache(); /// /// Clear metadata cache for specific C# type /// /// Object properties type void InvalidateSchemeCache() where TProps : class; /// /// Clear metadata cache for scheme by ID /// /// Scheme ID in database void InvalidateSchemeCache(long schemeId); /// /// Clear metadata cache for scheme by name /// /// Scheme name void InvalidateSchemeCache(string schemeName); // ===== STATISTICS AND MONITORING ===== /// /// Get detailed cache performance statistics /// CacheStatistics GetCacheStatistics(); /// /// Reset cache statistics (zero out counters) /// The cache itself remains untouched /// void ResetCacheStatistics(); // ===== CACHE PRELOADING (WARMUP) ===== /// /// Preload metadata for C# type /// Useful for performance optimization during application startup /// /// Object properties type Task WarmupCacheAsync(CancellationToken cancellationToken = default) where TProps : class; /// /// Preload metadata for array of C# types /// /// Array of types to preload /// Cancels the operation (OCE only; a rollback in flight always completes). Task WarmupCacheAsync(Type[] types, CancellationToken cancellationToken = default); /// /// Preload metadata for all known schemes /// Use carefully - can be resource-intensive /// Task WarmupAllSchemesAsync(CancellationToken cancellationToken = default); // ===== DIAGNOSTICS ===== /// /// Get diagnostic information about cache state /// Includes optimization recommendations /// CacheDiagnosticInfo GetCacheDiagnosticInfo(); /// /// Estimate current memory consumption by cache in bytes /// Approximate value for monitoring /// long EstimateMemoryUsage(); } }