108 lines
2.6 KiB
C#
108 lines
2.6 KiB
C#
using Microsoft.Extensions.Caching.Memory;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace YD_AllHeartRates.Commons.MemoryCaches
|
|
{
|
|
/// <summary>
|
|
/// 实例化缓存接口ICaching
|
|
/// </summary>
|
|
public class MemoryCaching : ICaching
|
|
{
|
|
private readonly IMemoryCache _cache;
|
|
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="cache"></param>
|
|
public MemoryCaching(IMemoryCache cache)
|
|
{
|
|
_cache = cache;
|
|
}
|
|
|
|
public object Get(string cacheKey)
|
|
{
|
|
return _cache.Get(cacheKey);
|
|
}
|
|
|
|
public void Update(string cacheKey, object cacheValue)
|
|
{
|
|
_cache.Remove(cacheKey);
|
|
|
|
_cache.Set(cacheKey, cacheValue, TimeSpan.FromSeconds(3600));
|
|
}
|
|
|
|
public void Set(string cacheKey, object cacheValue)
|
|
{
|
|
_cache.Set(cacheKey, cacheValue, TimeSpan.FromSeconds(3600));
|
|
}
|
|
|
|
public bool Exists(string key)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void LPush(string key, string val)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void RPush(string key, string val)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public object ListDequeue(string key)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public T ListDequeue<T>(string key) where T : class
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void ListRemove(string key, int keepIndex)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public bool AddObject(string key, object value, int expireSeconds = -1, bool isSliding = false)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public bool Add(string key, string value, int expireSeconds = -1, bool isSliding = false)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public bool Remove(string key)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void RemoveAll(IEnumerable<string> keys)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public T Get<T>(string key) where T : class
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
string ICaching.Get(string key)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public int GetSetCount(string key)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|