Soenneker.Validators.ExpiringKey 3.0.1078

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Validators.ExpiringKey --version 3.0.1078
                    
NuGet\Install-Package Soenneker.Validators.ExpiringKey -Version 3.0.1078
                    
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="Soenneker.Validators.ExpiringKey" Version="3.0.1078" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Validators.ExpiringKey" Version="3.0.1078" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Validators.ExpiringKey" />
                    
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 Soenneker.Validators.ExpiringKey --version 3.0.1078
                    
#r "nuget: Soenneker.Validators.ExpiringKey, 3.0.1078"
                    
#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 Soenneker.Validators.ExpiringKey@3.0.1078
                    
#: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=Soenneker.Validators.ExpiringKey&version=3.0.1078
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Validators.ExpiringKey&version=3.0.1078
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Validators.ExpiringKey

A validation module that checks for keys, stores them, expires them after an amount of time

Ideal for caching, session management, and more.

🚀 Features

  • Validate Key: Check if a key exists.
  • Add Key: Add a key with an expiration time.
  • Validate and Add: Validate if a key exists and add it if not.
  • Remove Key: Remove a key.

Installation

dotnet add package Soenneker.Validators.ExpiringKey

💻 Usage

IExpiringKeyValidator can be registered within DI, and injected:

public static async Task Main(string[] args)
{
    ...
    builder.Services.AddExpiringKeyValidatorAsSingleton();
}

or it can be initialized manually: new ExpiringKeyValidator().

Validate Key

Check if a key is present.

bool Validate(string key)

Add Key

Add a key with an expiration time.

void Add(string key, int expirationTimeMilliseconds)

Validate and Add Key

Validate a key and add it if it doesn't exist.

bool ValidateAndAdd(string key, int expirationTimeMilliseconds) // true if doesn't exist, false if it does

Remove Key

Remove a key.

void Remove(string key)

Example

var validator = new ExpiringKeyValidator();
validator.Add("key1", 5000); // 5 seconds

var invalid = validator.Validate("key1"); // false, key exists

await Task.Delay(7000); // wait 7 seconds

var validAfterTime = validator.Validate("key1"); // true, key does not exist
Product Compatible and additional computed target framework versions.
.NET 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. 
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
4.0.1299 36 4/23/2026
4.0.1298 64 4/21/2026
4.0.1297 91 4/14/2026
4.0.1296 99 3/13/2026
4.0.1295 88 3/12/2026
4.0.1294 98 3/12/2026
4.0.1293 87 3/12/2026
4.0.1290 101 3/12/2026
4.0.1288 95 3/12/2026
4.0.1286 95 3/11/2026
4.0.1285 96 3/11/2026
4.0.1284 96 3/10/2026
4.0.1283 97 3/10/2026
4.0.1282 98 3/10/2026
4.0.1281 103 3/10/2026
4.0.1280 92 3/10/2026
4.0.1279 96 3/10/2026
4.0.1278 91 3/9/2026
4.0.1276 96 3/9/2026
3.0.1078 188 2/25/2025
Loading failed