添加项目文件。

This commit is contained in:
dell
2023-03-03 16:07:50 +08:00
parent 2c462551b6
commit 011039960e
585 changed files with 362460 additions and 0 deletions

View File

@ -0,0 +1,54 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using HT.Cloud.Code;
namespace HT.Cloud.DataBase
{
public class SqlSugarCache : ICacheService
{
public void Add<TV>(string key, TV value)
{
CacheHelper.SetBySecond(key, value);
}
public void Add<TV>(string key, TV value, int cacheDurationInSeconds)
{
CacheHelper.SetBySecond(key, value, cacheDurationInSeconds);
}
public bool ContainsKey<TV>(string key)
{
return CacheHelper.Exists(key);
}
public TV Get<TV>(string key)
{
return CacheHelper.Get<TV>(key);
}
public IEnumerable<string> GetAllKey<TV>()
{
return CacheHelper.GetAllKey<TV>();
}
public TV GetOrCreate<TV>(string cacheKey, Func<TV> create, int cacheDurationInSeconds = int.MaxValue)
{
if (this.ContainsKey<TV>(cacheKey))
{
return this.Get<TV>(cacheKey);
}
else
{
var result = create();
this.Add(cacheKey, result, cacheDurationInSeconds);
return result;
}
}
public void Remove<TV>(string key)
{
CacheHelper.Remove(key);
}
}
}