Soenneker.Validators.ExpiringKey
4.0.1296
Prefix Reserved
dotnet add package Soenneker.Validators.ExpiringKey --version 4.0.1296
NuGet\Install-Package Soenneker.Validators.ExpiringKey -Version 4.0.1296
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="4.0.1296" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Validators.ExpiringKey" Version="4.0.1296" />
<PackageReference Include="Soenneker.Validators.ExpiringKey" />
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 4.0.1296
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Soenneker.Validators.ExpiringKey, 4.0.1296"
#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@4.0.1296
#: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=4.0.1296
#tool nuget:?package=Soenneker.Validators.ExpiringKey&version=4.0.1296
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions 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.
-
net10.0
- Soenneker.Dictionaries.ExpiringKey (>= 4.0.700)
- Soenneker.Validators.Validator (>= 4.0.722)
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.1296 | 86 | 3/13/2026 |
| 4.0.1295 | 77 | 3/12/2026 |
| 4.0.1294 | 84 | 3/12/2026 |
| 4.0.1293 | 78 | 3/12/2026 |
| 4.0.1290 | 89 | 3/12/2026 |
| 4.0.1288 | 84 | 3/12/2026 |
| 4.0.1286 | 84 | 3/11/2026 |
| 4.0.1285 | 85 | 3/11/2026 |
| 4.0.1284 | 81 | 3/10/2026 |
| 4.0.1283 | 85 | 3/10/2026 |
| 4.0.1282 | 87 | 3/10/2026 |
| 4.0.1281 | 92 | 3/10/2026 |
| 4.0.1280 | 81 | 3/10/2026 |
| 4.0.1279 | 84 | 3/10/2026 |
| 4.0.1278 | 81 | 3/9/2026 |
| 4.0.1276 | 86 | 3/9/2026 |
| 4.0.1275 | 82 | 3/4/2026 |
| 4.0.1274 | 80 | 3/4/2026 |
| 4.0.1272 | 82 | 3/4/2026 |
| 4.0.1271 | 112 | 2/10/2026 |
Loading failed
Update dependency Soenneker.Dictionaries.ExpiringKey to 4.0.700 (#1579)