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()); }
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); } }
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); }
public long ZremRangeByScore(string key, long start, long end, int db = -1) => RedisBoss.GetDB(db).SortedSetRemoveRangeByScore(key, start, end);
public List <string> ZrangeByRank(string key, long start, long end, int db = -1) => RedisBoss.GetDB(db).SortedSetRangeByRank(key, start, end).ConvertToStringList();
public bool Zadd(string key, string val, double score, int db = -1) => RedisBoss.GetDB(db).SortedSetAdd(key, val, score);
public List <string> Sdiff(string first, string second, int db = -1) => RedisBoss.GetDB(db).SetCombine(SetOperation.Difference, first, second).ConvertToStringList();
public bool Srem(string key, string val, int db = -1) => RedisBoss.GetDB(db).SetRemove(key, val);
public string Spop(string key, int db = -1) => RedisBoss.GetDB(db).SetPop(key);
public string Lpop(string key, int db = -1) => RedisBoss.GetDB(db).ListLeftPop(key);
public List <string> Hvals(string hkey, int db = -1) => RedisBoss.GetDB(db).HashValues(hkey).ConvertToStringList();
public long Hlen(string hkey, int db = -1) => RedisBoss.GetDB(db).HashLength(hkey);
public bool HkeyExists(string hkey, int db = -1) => RedisBoss.GetDB(db).KeyExists(hkey);
public string Hget(string hkey, string key, int db = -1) => RedisBoss.GetDB(db).HashGet(hkey, key);
public bool Sadd(string key, string val, int db = -1) => RedisBoss.GetDB(db).SetAdd(key, val);
public long Scard(string key, int db = -1) => RedisBoss.GetDB(db).SetLength(key);
public string Rpop(string key, int db = -1) => RedisBoss.GetDB(db).ListRightPop(key);
public bool Smove(string sourceKey, string destKey, string val, int db = -1) => RedisBoss.GetDB(db).SetMove(sourceKey, destKey, val);
public long Rpush(string key, string val, int db = -1) => RedisBoss.GetDB(db).ListRightPush(key, val);
public List <string> Smember(string key, int db = -1) => RedisBoss.GetDB(db).SetMembers(key).ConvertToStringList();
public long Llen(string key, int db = -1) => RedisBoss.GetDB().ListLength(key);
public List <string> Sinter(string first, string second, int db = -1) => RedisBoss.GetDB(db).SetCombine(SetOperation.Intersect, first, second).ConvertToStringList();
public List <string> Lrange(string key, int start, int stop, int db = -1) => RedisBoss.GetDB(db).ListRange(key, start, stop).ConvertToStringList();
public long Zcount(string key, int db = -1) => RedisBoss.GetDB(db).SortedSetLength(key);
public long Linsert(string key, string preVal, string val, int db = -1) => RedisBoss.GetDB(db).ListInsertAfter(key, preVal, val);
public bool Zrem(string key, string val, int db = -1) => RedisBoss.GetDB().SortedSetRemove(key, val);
public string Lindex(string key, int index, int db = -1) => RedisBoss.GetDB(db).ListGetByIndex(key, index);
public double?ZScore(string key, string val, int db = -1) => RedisBoss.GetDB(db).SortedSetScore(key, val);
public long Lrem(string key, string val, int count, int db = -1) => RedisBoss.GetDB(db).ListRemove(key, val, count);