Exemple #1
0
        public void Hset(string hkey, Dictionary <string, string> keyValues, int db = -1)
        {
            var entries = new List <HashEntry>();

            foreach (var item in keyValues)
            {
                entries.Add(new HashEntry(item.Key, item.Value));
            }

            RedisBoss.GetDB(db).HashSet(hkey, entries.ToArray());
        }
Exemple #2
0
        public T Hget <T>(string hkey, string key, int db = -1)
        {
            var val = RedisBoss.GetDB(db).HashGet(hkey, key);

            if (!string.IsNullOrEmpty(val))
            {
                return(JsonConvert.DeserializeObject <T>(val));
            }

            return(default(T));
        }
        public void Hset <T>(string hkey, Dictionary <string, T> keyValues, int db = -1)
        {
            var entries = new List <HashEntry>();

            try
            {
                foreach (var item in keyValues)
                {
                    Hset(hkey, item.Key, item.Value);
                }
            }
            catch
            {
                RedisBoss.GetDB(db).KeyDelete(hkey);
            }
        }
Exemple #4
0
        public Dictionary <string, string> HGetAll(string hkey, int db = -1)
        {
            var dic     = new Dictionary <string, string>();
            var entries = RedisBoss.GetDB().HashGetAll(hkey);

            if (entries == null || entries.Length <= 0)
            {
                return(null);
            }

            foreach (var item in entries.ToDictionary())
            {
                dic.Add(item.Key, item.Value);
            }

            return(dic);
        }
Exemple #5
0
 public long ZremRangeByScore(string key, long start, long end, int db = -1) => RedisBoss.GetDB(db).SortedSetRemoveRangeByScore(key, start, end);
Exemple #6
0
 public List <string> ZrangeByRank(string key, long start, long end, int db = -1) => RedisBoss.GetDB(db).SortedSetRangeByRank(key, start, end).ConvertToStringList();
Exemple #7
0
 public bool Zadd(string key, string val, double score, int db = -1) => RedisBoss.GetDB(db).SortedSetAdd(key, val, score);
Exemple #8
0
 public List <string> Sdiff(string first, string second, int db = -1) =>
 RedisBoss.GetDB(db).SetCombine(SetOperation.Difference, first, second).ConvertToStringList();
Exemple #9
0
 public bool Srem(string key, string val, int db = -1) => RedisBoss.GetDB(db).SetRemove(key, val);
Exemple #10
0
 public string Spop(string key, int db = -1) => RedisBoss.GetDB(db).SetPop(key);
Exemple #11
0
 public string Lpop(string key, int db = -1) => RedisBoss.GetDB(db).ListLeftPop(key);
Exemple #12
0
 public List <string> Hvals(string hkey, int db = -1) => RedisBoss.GetDB(db).HashValues(hkey).ConvertToStringList();
Exemple #13
0
 public long Hlen(string hkey, int db = -1) => RedisBoss.GetDB(db).HashLength(hkey);
Exemple #14
0
 public bool HkeyExists(string hkey, int db = -1) => RedisBoss.GetDB(db).KeyExists(hkey);
Exemple #15
0
 public string Hget(string hkey, string key, int db = -1) => RedisBoss.GetDB(db).HashGet(hkey, key);
Exemple #16
0
 public bool Sadd(string key, string val, int db = -1) => RedisBoss.GetDB(db).SetAdd(key, val);
Exemple #17
0
 public long Scard(string key, int db = -1) => RedisBoss.GetDB(db).SetLength(key);
Exemple #18
0
 public string Rpop(string key, int db = -1) => RedisBoss.GetDB(db).ListRightPop(key);
Exemple #19
0
 public bool Smove(string sourceKey, string destKey, string val, int db = -1) => RedisBoss.GetDB(db).SetMove(sourceKey, destKey, val);
Exemple #20
0
 public long Rpush(string key, string val, int db = -1) => RedisBoss.GetDB(db).ListRightPush(key, val);
Exemple #21
0
 public List <string> Smember(string key, int db = -1) => RedisBoss.GetDB(db).SetMembers(key).ConvertToStringList();
Exemple #22
0
 public long Llen(string key, int db = -1) => RedisBoss.GetDB().ListLength(key);
Exemple #23
0
 public List <string> Sinter(string first, string second, int db = -1) =>
 RedisBoss.GetDB(db).SetCombine(SetOperation.Intersect, first, second).ConvertToStringList();
Exemple #24
0
 public List <string> Lrange(string key, int start, int stop, int db = -1) => RedisBoss.GetDB(db).ListRange(key, start, stop).ConvertToStringList();
Exemple #25
0
 public long Zcount(string key, int db = -1) => RedisBoss.GetDB(db).SortedSetLength(key);
Exemple #26
0
 public long Linsert(string key, string preVal, string val, int db = -1) => RedisBoss.GetDB(db).ListInsertAfter(key, preVal, val);
Exemple #27
0
 public bool Zrem(string key, string val, int db = -1) => RedisBoss.GetDB().SortedSetRemove(key, val);
Exemple #28
0
 public string Lindex(string key, int index, int db = -1) => RedisBoss.GetDB(db).ListGetByIndex(key, index);
Exemple #29
0
 public double?ZScore(string key, string val, int db = -1) => RedisBoss.GetDB(db).SortedSetScore(key, val);
Exemple #30
0
 public long Lrem(string key, string val, int count, int db = -1) => RedisBoss.GetDB(db).ListRemove(key, val, count);