LRU 1.0.3
dotnet add package LRU --version 1.0.3
NuGet\Install-Package LRU -Version 1.0.3
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.
<PackageReference Include="LRU" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LRU" Version="1.0.3" />
<PackageReference Include="LRU" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LRU --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LRU, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=LRU&version=1.0.3
#tool nuget:?package=LRU&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
LRU
This is a thread safe caching strategy implementation of Least Recently Used (LRU). It defines the policy to evict elements from the cache to make room for new elements when the cache is full, meaning it discards the least recently used items first.
A Least Recently Used (LRU) Cache organizes items in order of use, allowing you to quickly identify which item hasn't been used for the longest amount of time.
How to use it
var capacity = 3; //It will keep 3 most used keys.
var cache = new LeastRecentlyUsedCache<int, Client>(capacity); //Key and Value are generics
var client1 = new Client() { Id = 1, Name = "client 1", Address = "Street 1" };
cache.Add(1, client1);
var client2 = new Client() { Id = 2, Name = "client 2", Address = "Street 2" };
cache.Add(2, client2);
var client3 = new Client() { Id = 3, Name = "client 3", Address = "Street 3" };
cache.Add(3, client3);
var client4 = new Client() { Id = 4, Name = "client 4", Address = "Street 4" };
cache.Add(4, client4);
var clientSearchId = 2;
if (cache.TryGetValue(clientSearchId, out var clientSearch2))
{
Console.WriteLine($"{clientSearch2}"); //{ Id = 2, Name = "client 2", Address = "Street 2" }
}
var clientSearchIdNotOnCache = 1;
if (!cache.TryGetValue(clientSearchIdNotOnCache, out var clientSearchNotOnCache))
{
Console.WriteLine($"Client with Id: {clientSearchIdNotOnCache} not found cache."); //Client with Id: 1 not found cache.
}
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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.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.