ProactiveCaching
is a .NET library designed to provide proactive caching functionality. Its core philosophy is to prioritize user experience by ensuring data is always available instantly, with no wait time. Based on 7.0 / .NET Standard.
-
Proactive Refreshes: Instead of waiting for a request to retrieve data,
ProactiveCaching
periodically refreshes the cache at specified intervals. This ensures that the data is always up-to-date and ready to be served. -
Atomic Data Switch: Data transitions from old to new occur atomically. When new data is ready, it replaces the old cache instantaneously, ensuring that clients always retrieve the latest available data without any delay.
-
Fault Tolerance: If fetching the new data fails for any reason,
ProactiveCaching
ensures that the old data remains intact and available. This resilience guarantees that users are not left without data due to intermittent issues or failures.
-
Flexible Data Sources: Can work with any asynchronous data source.
-
Exception Handling: Gracefully handles exceptions during data fetch operations.
-
Async-Aware: Fully asynchronous API to work seamlessly in modern .NET applications.
Leverage ProactiveCaching
to optimize your applications by always having fresh data at your fingertips, without compromising on speed or reliability.
-
Installation: Install the
ProactiveCaching
NuGet package.Install-Package ProactiveCaching
-
Basic Usage:
var proactiveCache = new ProactiveCache<string>( async () => await GetDataFromDatabase(), refreshPeriod: TimeSpan.FromMinutes(5) ); var data = await proactiveCache.GetDataAsync();
Refer to the provided tests in the ProactiveCaching.Tests
project for more advanced use-cases and examples.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please ensure to update tests as appropriate.