using CoreCms.Net.Utility;
using EasyCaching.Core;
using SqlSugar;
using System;
using System.Collections.Generic;
namespace CoreCms.Net.Caching.SqlSugar
{
///
/// 仅供ORM缓存使用
///
public class SqlSugarCache : ICacheService
{
private static readonly IEasyCachingProvider cache = Storage.GetService();
public void Add(string key, V value)
{
cache.Set(key, value, TimeSpan.FromSeconds(int.MaxValue));
}
public void Add(string key, V value, int cacheDurationInSeconds)
{
cache.Set(key, value, TimeSpan.FromSeconds(cacheDurationInSeconds));
}
public bool ContainsKey(string key)
{
return cache.Exists(key);
}
public V Get(string key)
{
return cache.Get(key).Value;
}
public IEnumerable GetAllKey()
{
return cache.GetByPrefix