mirror of
https://github.com/WowUp/WowUp.git
synced 2026-04-23 15:27:03 -04:00
22 lines
553 B
C#
22 lines
553 B
C#
using Microsoft.Extensions.Caching.Memory;
|
|
using System;
|
|
|
|
namespace WowUp.WPF.Extensions
|
|
{
|
|
public static class CacheExtensions
|
|
{
|
|
public static void CacheForAbsolute(this IMemoryCache cache, string cacheKey, object value, TimeSpan expiresIn)
|
|
{
|
|
if (cache == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var cacheEntryOptions = new MemoryCacheEntryOptions()
|
|
.SetAbsoluteExpiration(expiresIn);
|
|
|
|
cache.Set(cacheKey, value, cacheEntryOptions);
|
|
}
|
|
}
|
|
}
|