Pustalorc.FrequencyCache
2.0.0
dotnet add package Pustalorc.FrequencyCache --version 2.0.0
NuGet\Install-Package Pustalorc.FrequencyCache -Version 2.0.0
<PackageReference Include="Pustalorc.FrequencyCache" Version="2.0.0" />
paket add Pustalorc.FrequencyCache --version 2.0.0
#r "nuget: Pustalorc.FrequencyCache, 2.0.0"
// 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 Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.1
- JetBrains.Annotations (>= 2021.3.0)
- Microsoft.NETCore.Platforms (>= 6.0.1)
-
.NETFramework 4.8
- JetBrains.Annotations (>= 2021.3.0)
- Microsoft.NETCore.Platforms (>= 6.0.1)
-
.NETStandard 2.0
- JetBrains.Annotations (>= 2021.3.0)
- Microsoft.NETCore.Platforms (>= 6.0.1)
-
.NETStandard 2.1
- JetBrains.Annotations (>= 2021.3.0)
- Microsoft.NETCore.Platforms (>= 6.0.1)
-
net5.0
- JetBrains.Annotations (>= 2021.3.0)
- Microsoft.NETCore.Platforms (>= 6.0.1)
-
net6.0
- JetBrains.Annotations (>= 2021.3.0)
- Microsoft.NETCore.Platforms (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
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.