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

namespace LQKJ.K3.PeiXunSystem.WebApi
{
  public  class MemoryHelper
    {
        private static IMemoryCache _memoryCache = null;
        static MemoryHelper()
        {
            if (_memoryCache == null)
            {
                _memoryCache = new MemoryCache(new MemoryCacheOptions());
            }
        }

        public void SetMemory(string key, object value, int exprireMins)
        {
            _memoryCache.Set(key, value, TimeSpan.FromMinutes(exprireMins));
        }

         public object GetMemory(string key)
        {
            return _memoryCache.Get(key);
        }
        //public object CreateMemory(string Key,string Sql)
        //{
        //    _memoryCache.GetOrCreate(Key,(e)=> { })
        //}
    }
}
