public void Set(string key, object val, int cacheTime) { string jsonString = JsonUtls.ToJson(val); byte[] entryBytes = Encoding.UTF8.GetBytes(jsonString); TimeSpan expiresIn = TimeSpan.FromMinutes(cacheTime); _db.StringSet(key, entryBytes, expiresIn); }
public T Get <T>(string key) { RedisValue rValue = _db.StringGet(key); if (!rValue.HasValue) { return(default(T)); } string jsonString = Encoding.UTF8.GetString(rValue); return(JsonUtls.FromJson <T>(jsonString)); }