v3.0.1
v3.0.1
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user