JJS.Cache
1.0.4
dotnet add package JJS.Cache --version 1.0.4
NuGet\Install-Package JJS.Cache -Version 1.0.4
<PackageReference Include="JJS.Cache" Version="1.0.4" />
<PackageVersion Include="JJS.Cache" Version="1.0.4" />
<PackageReference Include="JJS.Cache" />
paket add JJS.Cache --version 1.0.4
#r "nuget: JJS.Cache, 1.0.4"
#:package JJS.Cache@1.0.4
#addin nuget:?package=JJS.Cache&version=1.0.4
#tool nuget:?package=JJS.Cache&version=1.0.4
JJS.Cache
A CacheService to cache values in memory
Installation
dotnet add package JJS.Cache
Usage
using JJS.Cache;
var builder = WebApplication.CreateBuilder();
builder.Services.UseCacheService(builder.Configuration);
var app = builder.Build();
Example
using JJS.Cache;
using System.Threading.Tasks;
public class MyService(ICacheService cacheService)
{
public async Task<string> GetCachedValueAsync()
{
var value = await cacheService.GetOrSetAsync<string>("test-key", async () =>
{
// Simulate a long-running operation
await Task.Delay(1000);
return "Hello, World!";
});
if (value == null)
{
return "valueFactory returned null";
}
return value;
}
}
Configuration
Configure the default expiration time for the cache in milliseconds in the appsettings.json file. If not set, the default value is 60000 milliseconds (1 minute).
{
"Cache": {
"DefaultExpiration": 60000
}
}
Dependencies
Microsoft.Extensions.Logging.ILogger is used for logging.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
If you would like to contribute to this project, please fork the repository and submit a pull request. We welcome contributions of all kinds, including bug fixes, new features, and documentation improvements.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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. |
-
net8.0
- Microsoft.Extensions.Configuration.Binder (>= 9.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
-
net9.0
- Microsoft.Extensions.Configuration.Binder (>= 9.0.5)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.