SmartCache.NET is a lightweight, high-performance caching executor for .NET applications. Designed with performance and simplicity in mind, it enables developers to optimize their code by reducing redundant operations using thread-safe, in-memory caching techniques.
ConcurrentDictionary
and lock controlTo use SmartCache.NET, simply wrap your expensive code block with:
var result = await Executor.Instance.GetDataAsync(() =>
{
return ExpensiveOperation();
}, paramValues, 30, 10); // Cache for 30 secs, refresh after 10
Under the hood, SmartCache.NET:
The included Program.cs
demo simulates 10 parallel requests. Despite concurrency, the executor ensures only one actual execution happens:
---- Starting parallel calls ---- [CodeBlock] Executed by Thread: 5 [Total CodeBlock Executions]: 1 [Total Time]: 510 ms
You can install the NuGet package (coming soon) or clone the repo:
git clone https://github.com/MuhammadOmerKhan/SmartCache.NET.git
We welcome contributions, feedback, and stars ⭐ on GitHub!
SmartCache.NET is released under the MIT License.