using System;
using Microsoft.Extensions.Caching.Memory;
namespace Tiger.Helper
{
public static class MemoryCacheHelper
{
private static MemoryCache cache = new MemoryCache(new MemoryCacheOptions());
public static T GetCacheValue<T>(string key)
{
T val = default(T);
cache.TryGetValue<T>(key, out val);
return val;
}
public static void SetChacheValue<T>(string key, T value, double s)
{
cache.Set<T>(key, value, new MemoryCacheEntryOptions
{
SlidingExpiration = TimeSpan.FromSeconds(s)
});
}
}
}