pvNugsCacheNc10Memory 10.0.3

dotnet add package pvNugsCacheNc10Memory --version 10.0.3
                    
NuGet\Install-Package pvNugsCacheNc10Memory -Version 10.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="pvNugsCacheNc10Memory" Version="10.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="pvNugsCacheNc10Memory" Version="10.0.3" />
                    
Directory.Packages.props
<PackageReference Include="pvNugsCacheNc10Memory" />
                    
Project file
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 pvNugsCacheNc10Memory --version 10.0.3
                    
#r "nuget: pvNugsCacheNc10Memory, 10.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.
#:package pvNugsCacheNc10Memory@10.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=pvNugsCacheNc10Memory&version=10.0.3
                    
Install as a Cake Addin
#tool nuget:?package=pvNugsCacheNc10Memory&version=10.0.3
                    
Install as a Cake Tool

pvNugsCacheNc10Memory

License .NET NuGet

Overview

pvNugsCacheNc10Memory is a high-performance, thread-safe in-memory caching solution for .NET Core 10 applications. Built on top of Microsoft.Extensions.Caching.Memory, it provides a simple abstraction for storing and retrieving cached data with configurable time-to-live (TTL) settings and integrated logging.

Key Features

  • In-memory caching using IMemoryCache
  • Configurable default and per-item TTL
  • Thread-safe operations
  • Trace logging for cache hit/miss/set/remove events
  • Strongly-typed generic API
  • Async methods with cancellation token support
  • Simple dependency injection setup
  • Configuration-driven defaults

Installation

dotnet add package pvNugsCacheNc10Memory

Requirements

  • .NET Core 10.0 or higher
  • C# 13.0 or higher

Quick Start

1) Configure appsettings.json

{
  "PvNugsCacheConfig": {
    "DefaultTimeToLive": "00:10:00"
  }
}

2) Register services

using pvNugsCacheNc10Memory;

var builder = WebApplication.CreateBuilder(args);

// Registers IMemoryCache and IPvNugsCache
builder.Services.TryAddPvNugsCacheMemory(builder.Configuration);

var app = builder.Build();

3) Use the cache

using pvNugsCacheNc10Abstractions;

public class MyService
{
    private readonly IPvNugsCache _cache;

    public MyService(IPvNugsCache cache)
    {
        _cache = cache;
    }

    public async Task<User> GetUserAsync(string userId)
    {
        var cacheKey = $"user:{userId}";

        var cachedUser = await _cache.GetAsync<User>(cacheKey);
        if (cachedUser != null)
            return cachedUser;

        var user = await LoadUserFromDatabaseAsync(userId);
        await _cache.SetAsync(cacheKey, user, TimeSpan.FromMinutes(5));

        return user;
    }

    public async Task UpdateUserAsync(User user)
    {
        await SaveUserToDatabaseAsync(user);
        await _cache.RemoveAsync($"user:{user.Id}");
    }
}

API Reference

IPvNugsCache

SetAsync
Task SetAsync<TValue>(
    string key,
    TValue value,
    TimeSpan? timeToLive = null,
    CancellationToken cancellationToken = default)

Stores a value in the cache with an optional TTL.

GetAsync
Task<TValue?> GetAsync<TValue>(
    string key,
    CancellationToken cancellationToken = default)

Retrieves a value from the cache.

RemoveAsync
Task RemoveAsync(
    string key,
    CancellationToken cancellationToken = default)

Removes a cached item.

Configuration

PvNugsCacheConfig

Property Type Description
DefaultTimeToLive TimeSpan? Default expiration time for cached items. If null, items do not expire automatically.

Logging

The cache integrates with the pvNugs logging abstractions and emits trace-level logs for key operations:

  • Cache hit
  • Cache miss
  • Cache set
  • Cache remove

Dependencies

  • Microsoft.Extensions.Caching.Memory (10.0.9)
  • Microsoft.Extensions.Options.ConfigurationExtensions (10.0.9)
  • pvNugsCacheNc10Abstractions (10.0.0)
  • pvNugsCacheNc10Abstractions - cache interface definitions
  • pvNugsLoggerNc10Abstractions - logging abstractions
  • pvNugsLoggerNc10Seri - Serilog-based logger implementation

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.3 97 8/10/2026
10.0.2 126 6/11/2026
10.0.1 115 6/11/2026
10.0.0 115 6/11/2026

Updated pvNugsLoggerNc10Abstractions dependency from 10.0.0 to 10.0.1