CypherPotato.MemoryCacheStorage
1.0.0
See the version list below for details.
dotnet add package CypherPotato.MemoryCacheStorage --version 1.0.0
NuGet\Install-Package CypherPotato.MemoryCacheStorage -Version 1.0.0
<PackageReference Include="CypherPotato.MemoryCacheStorage" Version="1.0.0" />
<PackageVersion Include="CypherPotato.MemoryCacheStorage" Version="1.0.0" />
<PackageReference Include="CypherPotato.MemoryCacheStorage" />
paket add CypherPotato.MemoryCacheStorage --version 1.0.0
#r "nuget: CypherPotato.MemoryCacheStorage, 1.0.0"
#:package CypherPotato.MemoryCacheStorage@1.0.0
#addin nuget:?package=CypherPotato.MemoryCacheStorage&version=1.0.0
#tool nuget:?package=CypherPotato.MemoryCacheStorage&version=1.0.0
MemoryCacheStorage
Written by CypherPotato
This package provides the ability to store objects for a period of time and retrieve them later. If the timeout time is exceeded, the file is dereferenced and the GC does the work of collecting the object if it is not referenced later.
There is no timer or recurrence. No objects are copied or serialized. The class stores the reference to the object, and after the time it runs in an asynchronous task, the pointer is released.
Setting objects
// initialize the new cache object
var cache = new MemoryCacheStorage();
cache.DefaultExpirity = TimeSpan.FromSeconds(30);
// Caches the object below for the default time defined above (30 seconds)
// and gets an ID for the stored object.
int id = cache.Set(myCachedObject);
// Caches the object for 30 seconds, sets an tag on it and gets the ID
id = cache.Set(myCachedObject, "my-tag");
// Caches the object for 5 minutes (override the default), set a tag
// and returns the id
id = cache.Set(myCachedObject, TimeSpan.FromMinutes(5), "tag");
// Caches an object using multiple tags
id = cache.Set(myCachedObject, TimeSpan.FromHours(3), new string[] { "tag1", "tag2" });
Retrieves cacheds objects
// tries to retrieve an cached object by their ID
if (!cache.TryGetValue(id, out object? cachedValue)) {
// couldn't find the cached object
} else {
// found the cached object
}
// tries to retrieve an cached object by one of their tags
if (!cache.TryGetValue("tag1", out object? cachedValue)) {
// couldn't find the cached object by the tag
} else {
// found the cached object
}
// tries to get an cached object, and converts it on fly
if (cache.TryGetValue("tag3", out MyClassObject? cachedValue)) {
// cachedValue was found
} else {
// not found
}
// retrieves multiple cached objects by tag
object?[] cachedObjects = cache.GetValuesByTag("tag1").ToArray();
// retrieves multiple cached objects by predicate
object?[] cachedObjects = cache
.GetValuesByTag(tags => tags.Contains("tag1") && tags.Contains("tag2"))
.ToArray();
// gets the count of cached objects
int cachedObjects = cache.Count;
Invalidate objects
// force immediate invalidation of object by one of their tags
int invalidatedObjects = cache.Invalidate("tag1");
// force immediate invalidation of object by one of their ID
int invalidatedObjects = cache.Invalidate(3);
// force immediate invalidation of all objects matching the tag
int invalidatedObjects = cache.Invalidate(tags => tags.Length > 3);
// clears the cache
cache.Clear();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
-
net6.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CypherPotato.MemoryCacheStorage:
| Package | Downloads |
|---|---|
|
Sisk.Monitoring
This package provides a way to export documentation from your Sisk API. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on CypherPotato.MemoryCacheStorage:
| Repository | Stars |
|---|---|
|
sisk-http/core
Sisk's request and response processor mainframe source code.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.10.0 | 108 | 4/18/2026 |
| 2.9.0 | 146 | 1/14/2026 |
| 2.8.0 | 174 | 10/18/2025 |
| 2.7.1 | 426 | 7/25/2025 |
| 2.4.0 | 208 | 12/24/2024 |
| 2.3.0 | 232 | 9/19/2024 |
| 2.1.0 | 175 | 9/2/2024 |
| 2.0.1 | 213 | 7/10/2024 |
| 2.0.0 | 236 | 6/21/2024 |
| 1.3.0 | 248 | 4/22/2024 |
| 1.2.3 | 235 | 4/17/2024 |
| 1.2.2 | 327 | 12/6/2023 |
| 1.2.1 | 219 | 12/1/2023 |
| 1.2.0 | 201 | 12/1/2023 |
| 1.1.0 | 242 | 11/9/2023 |
| 1.0.0 | 286 | 5/29/2023 |