Beispiel #1
0
        public bool Add <T>(T data)
        {
            if (data == null || !IsCachingServer)
            {
                return(false);
            }
            try
            {
                PropertyInfo[] properties = typeof(T).GetProperties();

                var key = Helper.GetClassName <T>() + ":" + properties[0].GetValue(data).ToString();
                Tuple.Create(key, data);
                //Find key
                if (Sut.Exists(key))
                {
                    if (Sut.Remove(key))
                    {
                        LogManager.Logger.LogError(new Exception("Error when remove object " + Helper.GetClassName <T>() + "- Key: " + key));
                        return(false);
                    }
                }
                //Add
                if (TimeExpried > 0)
                {
                    return(Sut.Add(key, data, TimeSpan.FromMinutes(TimeExpried)));
                }
                else
                {
                    return(Sut.Add(key, data));
                }
            }
            catch (Exception ex)
            {
                LogManager.Logger.LogError(ex);
                return(false);
            }
        }
Beispiel #2
0
 public bool Exists(string key) => client.Exists(keyPrefix + key);
 public bool IsAdd(string key)
 {
     return(_database.Exists(key));
 }
Beispiel #4
0
 public bool Contain(string key)
 {
     return(client.Exists(key));
 }
Beispiel #5
0
 private bool Exists(string key)
 {
     return(_redisClient.Exists(key));
 }
Beispiel #6
0
 public bool Exists <T>(object key)
 {
     return(_clientExt.Exists(RedisUtils.KeyBuilder <T>(key)));
 }