Pustalorc.FrequencyCache 2.0.0

.NET 5.0 .NET Standard 2.0 .NET Framework 4.6.1
NuGet\Install-Package Pustalorc.FrequencyCache -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package Pustalorc.FrequencyCache --version 2.0.0
<PackageReference Include="Pustalorc.FrequencyCache" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pustalorc.FrequencyCache --version 2.0.0
#r "nuget: Pustalorc.FrequencyCache, 2.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Pustalorc.FrequencyCache as a Cake Addin
#addin nuget:?package=Pustalorc.FrequencyCache&version=2.0.0

// Install Pustalorc.FrequencyCache as a Cake Tool
#tool nuget:?package=Pustalorc.FrequencyCache&version=2.0.0

First, create a class that inherits from ICacheConfiguration like so:

public class ExampleConfiguration : ICacheConfiguration
    public bool EnableCacheRefreshes => true;
    public double CacheRefreshRequestInterval => 1500;
    public ulong CacheSize => 15;

This will be used to configure the cache to function in a specific way.

Next, create a new instance of the Cache<T1, T2> class and pass it an instance of the previous class you created. Make sure to define T1 as the class that you wish to cache, and T2 as the class of the key that will identify T1 when doing lookups in the cache.

configuration = new ExampleConfiguration;
cache = new Cache<T1, T2>(configuration, StringComparer.OrdinalIgnoreCase);

Important Note: As of 1.2.x, a comparer is required to compare T2 in the lookup dictionary.

And you are done!

You can now use cache.GetItemInCache(T2) to lookup an item in cache, or cache.StoreUpdateItem(T2, T1) to store or update any item in the cache. For example:

configuration = new ExampleConfiguration;
cache = new CacheManager<Query, string>(configuration, StringComparer.OrdinalIgnoreCase);
cache.StoreUpdateItem("TableLookup", new Query("SELECT * FROM TABLE `users`;"));

var cachedElement = cache.GetItemInCache("TableLookup");
var query = cachedElement.Item;
query.String = "SELECT * FROM TABLE `users` WHERE `name`='admin';";
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 115 2/8/2022
1.2.2 81 2/8/2022
1.2.1 164 12/17/2021
1.2.0 302 9/23/2021
1.1.0 400 8/1/2020
1.0.2 390 7/9/2020
1.0.0 434 7/7/2020

Switched to properties rather than fields on the cache.
           Added new ReloadConfiguration method.
           Made Dispose virtual.
           Updated some of the Xml Documentation.
           Removed ModifyCacheRefreshInterval.
           Removed default/example configuration.