using KBR.Shared.Cache.Models; using Microsoft.Extensions.Caching.Distributed; namespace KBR.Shared.Cache { public static class CacheHelpers { private static readonly string _userSessions = nameof(_userSessions); private static string UserSessionsKey(string key) => $"{_userSessions}-{key}"; public static async Task SetUserSessionsCacheAsync(IAppDistributedCache cache, string userId, UserSessionModel sessions, CancellationToken cancellationToken = default) { await cache.SetAsync(UserSessionsKey(userId), sessions, GetOptions(), cancellationToken); } private static DistributedCacheEntryOptions GetOptions() { return new DistributedCacheEntryOptions { AbsoluteExpiration = DateTime.MaxValue }; } } }