using Femto.Modules.Auth.Models; using Microsoft.Extensions.Caching.Memory; namespace Femto.Modules.Auth.Infrastructure; internal class SessionStorage(MemoryCacheOptions? options = null) { private readonly IMemoryCache _storage = new MemoryCache(options ?? new MemoryCacheOptions()); public Task GetSession(string id) { return Task.FromResult(this._storage.Get(id)); } public Task AddSession(Session session) { using var entry = this._storage.CreateEntry(session.Id); entry.Value = session; entry.SetAbsoluteExpiration(session.Expires); return Task.CompletedTask; } public Task DeleteSession(string id) { this._storage.Remove(id); return Task.CompletedTask; } }