LocalObjectCache 1.0.1
dotnet add package LocalObjectCache --version 1.0.1
NuGet\Install-Package LocalObjectCache -Version 1.0.1
<PackageReference Include="LocalObjectCache" Version="1.0.1" />
paket add LocalObjectCache --version 1.0.1
#r "nuget: LocalObjectCache, 1.0.1"
// Install LocalObjectCache as a Cake Addin #addin nuget:?package=LocalObjectCache&version=1.0.1 // Install LocalObjectCache as a Cake Tool #tool nuget:?package=LocalObjectCache&version=1.0.1
LocalObjectCache
An object cache to store objects temporarily & locally for .NET applications.
Required
Usages
- To store the HTTP response back, in order to not hit an API endpoint too much (avoiding HTTP 429 status code)
How does it work?
Internally, it uses LiteDB to store objects in a local file.
How to use
For a quick start, you can use the static LocalObjectCache.Default
. It creates a cache with the following default settings:
- Object validity timespan: 24hours from the time of object insertion
- DB filename: cache.db
- DB file path: local executing directory
Alternatively, you can instantiate LocalObjectCache
and configure it the way you want it and use it.
You can use Index
attribute on the properties that you want to use as ID or you want to enforce uniqueness in the cache.
The following methods help you to interact with the cache:
InsertOne<T>
Inserts an object of type T into the cache. The cache validity starts from the time of insertion.
InsertOne<ExchangeRate>(new ExchangeRate("USD", "EUR", 0.96))
GetOne<T>
Gets an object from the cache with the given predicate (in lambda format)
GetOne<ExchangeRate>(x => x.BaseCurrency.Equals("USD"))
InsertMany(IEnumerable<T>)
InsertMany<ExchangeRate>(new [] { new ExchangeRate("USD", "EUR", 0.96), new ExchangeRate("USD", "AUD", 1.50)})
GetMany
GetMany<ExchangeRate>(x => x.BaseCurrency.Equals("USD"))
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 is compatible. 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. |
NuGet packages (1)
Showing the top 1 NuGet packages that depend on LocalObjectCache:
Package | Downloads |
---|---|
HeliumApi.SDK
An unofficial SDK I created to use Helium Api in .NET applications (Console, Web or Mobile) |
GitHub repositories
This package is not used by any popular GitHub repositories.