Soenneker.Validators.ExpiringKey 2.1.41

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 2.1.41                
NuGet\Install-Package Soenneker.Validators.ExpiringKey -Version 2.1.41                
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="2.1.41" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Soenneker.Validators.ExpiringKey --version 2.1.41                
#r "nuget: Soenneker.Validators.ExpiringKey, 2.1.41"                
#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.
// Install Soenneker.Validators.ExpiringKey as a Cake Addin
#addin nuget:?package=Soenneker.Validators.ExpiringKey&version=2.1.41

// Install Soenneker.Validators.ExpiringKey as a Cake Tool
#tool nuget:?package=Soenneker.Validators.ExpiringKey&version=2.1.41                

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 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. 
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
2.1.402 35 10/3/2024
2.1.401 33 10/3/2024
2.1.400 19 10/3/2024
2.1.399 30 10/3/2024
2.1.398 30 10/3/2024
2.1.397 25 10/3/2024
2.1.396 34 10/3/2024
2.1.395 28 10/3/2024
2.1.394 33 10/3/2024
2.1.393 30 10/3/2024
2.1.392 33 10/2/2024
2.1.391 32 10/2/2024
2.1.390 31 10/2/2024
2.1.389 28 10/2/2024
2.1.388 34 10/2/2024
2.1.387 29 10/2/2024
2.1.386 31 10/2/2024
2.1.385 34 10/2/2024
2.1.384 35 10/2/2024
2.1.383 38 10/1/2024
2.1.382 41 10/1/2024
2.1.381 45 10/1/2024
2.1.380 45 10/1/2024
2.1.379 46 10/1/2024
2.1.378 53 10/1/2024
2.1.377 50 10/1/2024
2.1.376 54 10/1/2024
2.1.375 55 10/1/2024
2.1.374 68 9/29/2024
2.1.373 64 9/29/2024
2.1.372 70 9/29/2024
2.1.371 65 9/29/2024
2.1.370 73 9/29/2024
2.1.369 73 9/29/2024
2.1.368 76 9/29/2024
2.1.367 68 9/29/2024
2.1.366 64 9/27/2024
2.1.365 70 9/27/2024
2.1.364 66 9/27/2024
2.1.363 68 9/27/2024
2.1.362 65 9/27/2024
2.1.361 65 9/27/2024
2.1.360 66 9/27/2024
2.1.359 72 9/27/2024
2.1.358 74 9/27/2024
2.1.357 64 9/27/2024
2.1.356 65 9/27/2024
2.1.355 62 9/27/2024
2.1.354 72 9/27/2024
2.1.353 65 9/27/2024
2.1.352 63 9/27/2024
2.1.351 71 9/27/2024
2.1.350 77 9/27/2024
2.1.349 65 9/27/2024
2.1.348 67 9/26/2024
2.1.347 71 9/26/2024
2.1.346 77 9/26/2024
2.1.345 69 9/26/2024
2.1.344 76 9/26/2024
2.1.343 71 9/26/2024
2.1.342 74 9/26/2024
2.1.341 71 9/26/2024
2.1.340 69 9/26/2024
2.1.339 67 9/26/2024
2.1.338 69 9/26/2024
2.1.337 70 9/26/2024
2.1.336 68 9/26/2024
2.1.335 66 9/26/2024
2.1.334 73 9/26/2024
2.1.333 79 9/24/2024
2.1.332 75 9/23/2024
2.1.331 65 9/23/2024
2.1.330 76 9/23/2024
2.1.329 75 9/23/2024
2.1.328 74 9/23/2024
2.1.327 66 9/23/2024
2.1.326 84 9/23/2024
2.1.325 64 9/23/2024
2.1.324 73 9/23/2024
2.1.323 70 9/23/2024
2.1.322 75 9/23/2024
2.1.321 68 9/23/2024
2.1.320 63 9/23/2024
2.1.319 71 9/23/2024
2.1.318 81 9/23/2024
2.1.317 66 9/23/2024
2.1.316 66 9/23/2024
2.1.315 75 9/23/2024
2.1.314 62 9/23/2024
2.1.313 64 9/23/2024
2.1.312 69 9/19/2024
2.1.311 68 9/18/2024
2.1.310 72 9/18/2024
2.1.309 68 9/18/2024
2.1.308 77 9/18/2024
2.1.307 71 9/18/2024
2.1.306 77 9/18/2024
2.1.305 77 9/17/2024
2.1.304 79 9/17/2024
2.1.303 69 9/17/2024
2.1.302 67 9/17/2024
2.1.301 75 9/17/2024
2.1.300 75 9/17/2024
2.1.299 72 9/17/2024
2.1.297 65 9/17/2024
2.1.296 97 9/17/2024
2.1.295 83 9/17/2024
2.1.294 88 9/17/2024
2.1.293 90 9/17/2024
2.1.292 84 9/17/2024
2.1.291 90 9/17/2024
2.1.290 86 9/17/2024
2.1.289 89 9/16/2024
2.1.288 81 9/16/2024
2.1.287 86 9/16/2024
2.1.286 91 9/16/2024
2.1.285 88 9/16/2024
2.1.284 85 9/16/2024
2.1.283 88 9/16/2024
2.1.282 97 9/12/2024
2.1.281 94 9/12/2024
2.1.280 104 9/12/2024
2.1.279 89 9/12/2024
2.1.278 94 9/12/2024
2.1.277 100 9/12/2024
2.1.276 89 9/12/2024
2.1.275 88 9/11/2024
2.1.274 91 9/11/2024
2.1.273 90 9/11/2024
2.1.272 91 9/11/2024
2.1.271 86 9/11/2024
2.1.269 97 9/11/2024
2.1.268 85 9/11/2024
2.1.267 89 9/11/2024
2.1.266 99 9/11/2024
2.1.265 87 9/11/2024
2.1.264 89 9/11/2024
2.1.263 87 9/10/2024
2.1.262 89 9/10/2024
2.1.261 91 9/10/2024
2.1.260 89 9/10/2024
2.1.259 87 9/10/2024
2.1.258 85 9/10/2024
2.1.257 78 9/10/2024
2.1.256 79 9/10/2024
2.1.255 77 9/10/2024
2.1.254 84 9/10/2024
2.1.253 86 9/10/2024
2.1.252 82 9/10/2024
2.1.251 82 9/10/2024
2.1.249 86 9/10/2024
2.1.248 78 9/10/2024
2.1.247 79 9/9/2024
2.1.246 82 9/9/2024
2.1.244 82 9/9/2024
2.1.243 90 9/9/2024
2.1.242 82 9/9/2024
2.1.241 83 9/9/2024
2.1.239 86 9/9/2024
2.1.238 76 9/9/2024
2.1.237 88 9/9/2024
2.1.236 85 9/9/2024
2.1.235 91 9/7/2024
2.1.234 90 9/7/2024
2.1.233 88 9/7/2024
2.1.232 80 9/7/2024
2.1.231 84 9/7/2024
2.1.230 82 9/7/2024
2.1.229 91 9/7/2024
2.1.228 78 9/7/2024
2.1.227 102 9/6/2024
2.1.226 89 9/6/2024
2.1.225 93 9/6/2024
2.1.224 91 9/6/2024
2.1.223 80 9/6/2024
2.1.222 96 9/6/2024
2.1.221 85 9/6/2024
2.1.220 90 9/6/2024
2.1.219 97 9/5/2024
2.1.218 86 9/5/2024
2.1.217 81 9/5/2024
2.1.216 76 9/5/2024
2.1.215 90 9/5/2024
2.1.214 87 9/5/2024
2.1.213 89 9/5/2024
2.1.212 86 9/5/2024
2.1.211 92 9/5/2024
2.1.210 82 9/5/2024
2.1.209 93 9/5/2024
2.1.208 87 9/5/2024
2.1.207 85 9/5/2024
2.1.206 86 9/5/2024
2.1.205 85 9/5/2024
2.1.204 87 9/5/2024
2.1.203 84 9/4/2024
2.1.202 84 9/4/2024
2.1.201 89 9/4/2024
2.1.200 87 9/4/2024
2.1.199 97 9/4/2024
2.1.198 88 9/3/2024
2.1.197 85 9/3/2024
2.1.196 90 9/3/2024
2.1.195 87 9/3/2024
2.1.194 89 9/3/2024
2.1.193 82 9/3/2024
2.1.192 63 9/3/2024
2.1.191 77 9/3/2024
2.1.190 96 9/3/2024
2.1.189 90 9/3/2024
2.1.188 84 9/3/2024
2.1.187 83 9/3/2024
2.1.186 76 9/3/2024
2.1.185 88 8/30/2024
2.1.184 94 8/29/2024
2.1.183 83 8/29/2024
2.1.182 88 8/29/2024
2.1.181 88 8/29/2024
2.1.180 84 8/29/2024
2.1.179 87 8/29/2024
2.1.178 93 8/26/2024
2.1.177 98 8/26/2024
2.1.176 100 8/26/2024
2.1.175 91 8/26/2024
2.1.174 90 8/26/2024
2.1.173 92 8/26/2024
2.1.172 97 8/26/2024
2.1.171 117 8/21/2024
2.1.170 115 8/21/2024
2.1.169 116 8/21/2024
2.1.168 115 8/21/2024
2.1.167 113 8/21/2024
2.1.166 112 8/21/2024
2.1.165 111 8/21/2024
2.1.164 108 8/21/2024
2.1.163 117 8/20/2024
2.1.162 114 8/20/2024
2.1.161 110 8/20/2024
2.1.160 104 8/20/2024
2.1.159 105 8/20/2024
2.1.158 91 8/20/2024
2.1.157 104 8/20/2024
2.1.156 95 8/20/2024
2.1.155 108 8/20/2024
2.1.154 104 8/20/2024
2.1.153 104 8/20/2024
2.1.152 104 8/20/2024
2.1.151 101 8/20/2024
2.1.150 106 8/19/2024
2.1.149 94 8/19/2024
2.1.148 112 8/15/2024
2.1.147 108 8/15/2024
2.1.146 109 8/15/2024
2.1.145 109 8/15/2024
2.1.144 110 8/15/2024
2.1.143 101 8/15/2024
2.1.142 104 8/14/2024
2.1.141 108 8/14/2024
2.1.140 83 8/14/2024
2.1.139 93 8/14/2024
2.1.138 90 8/14/2024
2.1.137 109 8/13/2024
2.1.136 76 8/7/2024
2.1.135 73 8/7/2024
2.1.134 98 8/7/2024
2.1.133 91 8/7/2024
2.1.132 90 8/7/2024
2.1.131 88 8/7/2024
2.1.130 76 8/7/2024
2.1.129 88 8/6/2024
2.1.128 74 8/6/2024
2.1.127 64 8/6/2024
2.1.126 70 8/1/2024
2.1.125 59 8/1/2024
2.1.124 57 8/1/2024
2.1.123 68 8/1/2024
2.1.122 62 8/1/2024
2.1.121 79 8/1/2024
2.1.120 67 8/1/2024
2.1.117 62 7/25/2024
2.1.116 76 7/25/2024
2.1.115 71 7/25/2024
2.1.114 76 7/25/2024
2.1.113 79 7/25/2024
2.1.112 75 7/25/2024
2.1.111 80 7/25/2024
2.1.110 79 7/25/2024
2.1.109 79 7/25/2024
2.1.108 74 7/25/2024
2.1.107 71 7/25/2024
2.1.106 80 7/24/2024
2.1.105 77 7/24/2024
2.1.103 92 7/24/2024
2.1.102 79 7/20/2024
2.1.101 70 7/20/2024
2.1.100 83 7/20/2024
2.1.99 83 7/20/2024
2.1.98 82 7/20/2024
2.1.97 77 7/20/2024
2.1.96 82 7/14/2024
2.1.95 70 7/14/2024
2.1.94 72 7/14/2024
2.1.93 58 7/14/2024
2.1.92 74 7/14/2024
2.1.91 75 7/14/2024
2.1.90 77 7/14/2024
2.1.89 78 7/14/2024
2.1.88 75 7/14/2024
2.1.87 69 7/14/2024
2.1.86 79 7/11/2024
2.1.85 76 7/10/2024
2.1.84 77 7/10/2024
2.1.83 75 7/10/2024
2.1.82 82 7/10/2024
2.1.81 75 7/10/2024
2.1.80 66 7/10/2024
2.1.79 79 7/10/2024
2.1.76 58 7/10/2024
2.1.75 85 7/10/2024
2.1.74 74 7/10/2024
2.1.73 74 7/10/2024
2.1.72 66 7/10/2024
2.1.71 76 7/10/2024
2.1.70 70 7/10/2024
2.1.69 67 7/10/2024
2.1.66 66 7/10/2024
2.1.65 84 7/10/2024
2.1.64 83 7/9/2024
2.1.61 52 7/9/2024
2.1.60 75 7/9/2024
2.1.59 73 7/9/2024
2.1.58 84 7/9/2024
2.1.57 78 7/9/2024
2.1.56 95 7/9/2024
2.1.55 96 7/9/2024
2.1.54 87 7/9/2024
2.1.53 81 7/9/2024
2.1.52 81 7/9/2024
2.1.51 83 7/9/2024
2.1.50 79 7/9/2024
2.1.49 72 7/9/2024
2.1.48 90 7/9/2024
2.1.47 76 7/9/2024
2.1.46 101 7/9/2024
2.1.45 98 7/8/2024
2.1.44 70 7/8/2024
2.1.43 85 7/8/2024
2.1.42 98 7/8/2024
2.1.41 80 7/8/2024
2.1.40 90 7/8/2024
2.1.39 73 7/8/2024
2.1.38 74 7/8/2024
2.1.37 100 7/7/2024
2.1.36 80 7/7/2024
2.1.35 93 7/7/2024
2.1.34 75 7/7/2024
2.1.33 102 7/3/2024
2.1.32 86 7/3/2024
2.1.31 105 7/3/2024
2.1.30 93 7/3/2024
2.1.29 92 7/3/2024
2.1.28 90 7/3/2024
2.1.27 90 7/3/2024
2.1.26 82 7/3/2024
2.1.25 85 7/3/2024
2.1.24 104 6/27/2024
2.1.23 107 6/27/2024
2.1.22 105 6/27/2024
2.1.21 101 6/27/2024
2.1.20 89 6/22/2024
2.1.19 95 6/22/2024
2.1.18 101 6/22/2024
2.1.17 97 6/22/2024
2.1.16 94 6/22/2024
2.1.15 100 6/16/2024
2.1.14 89 6/16/2024
2.1.13 83 6/15/2024
2.1.12 95 6/15/2024
2.1.11 79 6/15/2024
2.1.10 90 6/15/2024
2.1.9 106 6/15/2024
2.1.8 76 6/15/2024
2.1.7 90 6/15/2024
2.1.6 94 6/15/2024
2.1.5 77 6/15/2024
2.1.4 93 6/12/2024
2.1.3 82 6/12/2024