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