2023-10-24 18:06:15 +08:00
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
2020-12-05 20:16:34 +08:00
|
|
|
|
|
|
|
|
|
namespace CacheTest
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
SugarCache cache = new SugarCache();
|
|
|
|
|
cache.Add("a", "1");
|
|
|
|
|
|
|
|
|
|
var x = cache.Get<string>("a");
|
|
|
|
|
cache.Add("a2", "11",5);
|
|
|
|
|
var x2 = cache.Get<string>("a2");
|
|
|
|
|
var isa= cache.ContainsKey<string>("a2");
|
|
|
|
|
var allKeys = cache.GetAllKey<string>();
|
|
|
|
|
var testr=cache.GetOrCreate<string>("a33",()=> { return "aaa"; },10);
|
|
|
|
|
cache.Remove<string>("aaaaaaaa");
|
|
|
|
|
cache.Remove<string>("a");
|
2023-10-24 18:06:15 +08:00
|
|
|
|
ICacheService myCache = cache;
|
|
|
|
|
|
|
|
|
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
|
|
|
|
|
{
|
|
|
|
|
ConnectionString = "server=.;uid=sa;pwd=sasa;database=SQLSUGAR4XTEST",
|
|
|
|
|
DbType = DbType.SqlServer,
|
|
|
|
|
IsAutoCloseConnection = true,
|
|
|
|
|
MoreSettings=new ConnMoreSettings() {
|
|
|
|
|
IsAutoRemoveDataCache = true,
|
|
|
|
|
},
|
|
|
|
|
ConfigureExternalServices = new ConfigureExternalServices()
|
|
|
|
|
{
|
|
|
|
|
DataInfoCacheService = myCache //配置我们创建的缓存类,具体用法看标题5
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
db.Fastest<Order>().BulkCopy(new System.Collections.Generic.List<Order>()
|
|
|
|
|
{
|
|
|
|
|
new Order(){ CreateTime=DateTime.Now, CustomId=1, Name="a" }
|
|
|
|
|
});
|
2020-12-05 20:16:34 +08:00
|
|
|
|
Console.WriteLine("Hello World!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|