Files
sanstudent/Api/Extensions/CacheExtensions.cs
aherman-san b8f03bf6d3
All checks were successful
SanStudent Multi-Project Deployment / deploy-api (push) Successful in 41s
SanStudent Multi-Project Deployment / deploy-frontadmin (push) Successful in 41s
SanStudent Multi-Project Deployment / deploy-frontstudent (push) Successful in 40s
Add project
2026-03-07 11:14:26 +01:00

17 lines
499 B
C#

using Common.Extensions;
using Microsoft.Extensions.Caching.Distributed;
using System.Text.Json;
namespace Api.Extensions;
public static class CacheExtensions
{
public static async Task SetWithExpirationTimeAsync<T>(this IDistributedCache cache, string key, T value, int minutes = 10)
{
var options = new DistributedCacheEntryOptions()
.SetAbsoluteExpiration(TimeSpan.FromMinutes(minutes));
await cache.SetStringAsync(key, value.ToJson(), options);
}
}