v3.0.1
This commit is contained in:
橙子
2021-06-02 20:00:25 +08:00
parent 6ea91cbaf6
commit e5063e1a4d
57 changed files with 1665 additions and 359 deletions

View File

@@ -17,33 +17,33 @@ namespace CC.Yi.Common.Cache
public bool AddCache<T>(string key, T value, DateTime expDate)
public static bool AddCache<T>(string key, T value, DateTime expDate)
{
return CacheWriter.AddCache<T>(key,value,expDate);
}
public bool AddCache<T>(string key, T value)
public static bool AddCache<T>(string key, T value)
{
return CacheWriter.AddCache<T>(key, value);
}
public bool RemoveCache(string key)
public static bool RemoveCache(string key)
{
return CacheWriter.RemoveCache(key);
}
public T GetCache<T>(string key)
public static T GetCache<T>(string key)
{
return CacheWriter.GetCache<T>(key);
}
public bool SetCache<T>(string key, T value, DateTime expDate)
public static bool SetCache<T>(string key, T value, DateTime expDate)
{
return CacheWriter.SetCache<T>(key,value,expDate);
}
public bool SetCache<T>(string key, T value)
{
public static bool SetCache<T>(string key, T value)
{
return CacheWriter.SetCache<T>(key, value);
}

View File

@@ -8,39 +8,92 @@ namespace CC.Yi.Common.Cache
public class RedisCache : ICacheWriter
{
private RedisClient client;
private string ip = "49.235.212.122";
private int port = 6379;
private string pwd = "Qz52013142020.";
public RedisCache()
{
client = new RedisClient("127.0.0.1", 6379, "52013142020.");
}
public void Dispose()
{
client.Dispose();
}
public bool AddCache<T>(string key, T value, DateTime expDate)
{
return client.Add<T>(key, value, expDate);
try
{
using (client = new RedisClient(ip, port, pwd))
{
return client.Add<T>(key, value, expDate);
}
}
catch
{
return false;
}
}
public bool AddCache<T>(string key, T value)
{
return client.Add<T>(key, value);
return client.Add<T>(key, value);
}
public bool RemoveCache(string key)
{
return client.Remove(key);
return client.Remove(key);
}
public T GetCache<T>(string key)
{
return client.Get<T>(key);
try
{
using (client = new RedisClient(ip, port, pwd))
{
return client.Get<T>(key);
}
}
catch
{
object p = new object();
return (T)p;
}
}
public bool SetCache<T>(string key,T value, DateTime expDate)
public bool SetCache<T>(string key, T value, DateTime expDate)
{
return client.Set<T>(key, value, expDate);
try
{
using (client = new RedisClient(ip, port, pwd))
{
return client.Set<T>(key, value, expDate);
}
}
catch
{
return false;
}
}
public bool SetCache<T>(string key, T value)
{
return client.Set<T>(key, value);
try
{
using (client = new RedisClient(ip, port, pwd))
{
return client.Set<T>(key, value);
}
}
catch
{
object p = new object();
return false;
}
}
}
}