MemoryCache.NetCore
1.0.0
See the version list below for details.
dotnet add package MemoryCache.NetCore --version 1.0.0
NuGet\Install-Package MemoryCache.NetCore -Version 1.0.0
<PackageReference Include="MemoryCache.NetCore" Version="1.0.0" />
paket add MemoryCache.NetCore --version 1.0.0
#r "nuget: MemoryCache.NetCore, 1.0.0"
// Install MemoryCache.NetCore as a Cake Addin #addin nuget:?package=MemoryCache.NetCore&version=1.0.0 // Install MemoryCache.NetCore as a Cake Tool #tool nuget:?package=MemoryCache.NetCore&version=1.0.0
MemoryCache.NetCore
Implementation of a parallel thread-safe in-memory caching system with save, and load support suited for 'state' programming.
Install
From a command prompt
dotnet add package MemoryCache.NetCore
Install-Package MemoryCache.NetCore
You can also search for package via your nuget ui / website:
https://www.nuget.org/packages/MemoryCache.NetCore/
Examples
You can find more examples in the github examples project.
// You can populate the cache at initialization time
using var cache = new MemoryCache
{
["caw"] = "caw caw caw"
};
// You can also access an entry directly by key. However you will need to cast from dynamic using this method.
var caw1 = (string)cache["caw"];
cache["caw"] = "caw caw caw 2";
// You can create new entries directly by key, and they can be complex types!
cache["object"] = new KeyValuePair<string, int>("test", 42);
// However, non-serializable complex types will be "ignored" during .Save
cache["stream"] = new MemoryStream(new byte[] { 32, 34 });
// You can also use the Read<T>, and Write<T> methods. These methods handle casting for you to and from dynamic.
var caw2 = cache.Read<string>("caw");
cache.Write("caw", "caw caw caw 3");
// You can save cache using either Binary, or Json serialization by specifying either byte[], or string as T during save.
var binary = cache.Save<byte[]>();
var json = cache.Save<string>();
// You can reload cache from another source such as disk, or socket. With the option of clearing any existing data.
cache.Load(binary);
Constructor
MemoryCache()
Methods
Write a dynamic value to cache without returning anything
void Write(string key, dynamic value)
Write a T value to cache returning the T value from cache
T Write<T>(string key, T value)
Read a value from cache returning as T
T Read<T>(string key)
Delete an entry from cache without returning anything
void Delete(string key)
Delete an entry from cache returning that value as T
T Delete<T>(string key)
Serialize all entries in cache marked as serializable. If you specify T as byte[] binary serialization is used. If you specify T as string json serialization is used.
T Save<T>()
Load serialized entries into cache. If you specify T as byte[] binary serialization is used. If you specify T as string json serialization is used.
void Load<T>(T data, bool clear = true)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MemoryCache.NetCore:
Package | Downloads |
---|---|
TimedMemoryCache.NetCore
mplementation of a parallel thread-safe in-memory caching system with save, and load support suited for 'state' programming and easy timeout support for time sensitive caching. |
GitHub repositories
This package is not used by any popular GitHub repositories.