using Microsoft.Extensions.Caching.Memory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace wispro.sp.api.Utility
{
    public class MyMemoryCache
    {
        static IMemoryCache _cache = new MemoryCache(new MemoryCacheOptions());

        public static bool TryGetValue(string strKey,out object outValue)
        {
            return _cache.TryGetValue(strKey, out outValue);
        }

        public static void SetValue(string strKey,object value)
        {
            var cacheEntryOptions = new MemoryCacheEntryOptions()
                    // Keep in cache for this time, reset time if accessed.
                    .SetSlidingExpiration(TimeSpan.FromHours(1));

            _cache.Set(strKey, value,cacheEntryOptions);
        }
    }
}
