/DistributedCacheExtensions

A .NET library for easy serialization and deserialization of objects in distributed caches.

Primary LanguageC#

DistributedCache.Extensions

NuGet

A .NET library for easy serialization and deserialization of objects in distributed caches.

Table of Contents

Installation

You can install the DistributedCache.Extensions library via NuGet:

dotnet add package DistributedCache.Extensions

Usage

Serialization

To serialize an object and store it in a distributed cache, use the Set method:

var user = new User("John", "Snow");
cache.Set("user:john_snow", user);

Deserialization

To retrieve and deserialize an object from a distributed cache, use the Get method:

var cachedUser = cache.Get<User>("user:john_snow");
if (cachedUser != null)
{
    // Use the deserialized object.
}