Pustalorc.FrequencyCache
1.0.2
See the version list below for details.
dotnet add package Pustalorc.FrequencyCache --version 1.0.2
NuGet\Install-Package Pustalorc.FrequencyCache -Version 1.0.2
<PackageReference Include="Pustalorc.FrequencyCache" Version="1.0.2" />
paket add Pustalorc.FrequencyCache --version 1.0.2
#r "nuget: Pustalorc.FrequencyCache, 1.0.2"
// Install Pustalorc.FrequencyCache as a Cake Addin #addin nuget:?package=Pustalorc.FrequencyCache&version=1.0.2 // Install Pustalorc.FrequencyCache as a Cake Tool #tool nuget:?package=Pustalorc.FrequencyCache&version=1.0.2
First, create a class that inherits from ICacheConfiguration
like so:
public class ExampleConfiguration : ICacheConfiguration
{
public double CacheRefreshRequestInterval => 1500;
public ulong CacheSize => 15;
}
Next, create a new instance of the CacheManager
class and pass it an instance of the previous class you created:
configuration = new ExampleConfiguration;
cache = new CacheManager(configuration);
Finally, you will need a "cache friendly" class. For this, simply create a class that inherits from IIdentifiable
:
public class CacheFriendly : IIdentifiable
{
public string UniqueIdentifier { get; }
public string AnotherType { get; }
}
Finally, you can use cache.GetItemInCache(IIdentifiable)
to get an item from cache, or cache.StoreUpdateItem(IIdentifiable)
to store or update an item in the cache. For example:
var element = cache.GetItemInCache(new CacheFriendly() {UniqueIdentifier = "1"});
element.AnotherType = "Yes";
cache.StoreUpdateItem(new CacheFriendly() {UniqueIdentifier = "1", AnotherType = "Hello World"})
Note that you can modify the memory data of a cached element, and the change should be reflected, but be sure to use a lock
statement if you ever plan on modifying data from a retrieved cached element, as well as when the cache update gets requested. If you do not do so, you might run into a race condition.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 | net35 is compatible. net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. 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 3.5
- No dependencies.
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.6.1
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Fixes an issue with the cache instantly throwing an exception due to a missing null check.