public List <string> GetMatchedKeys(IRedisKey key = null)
        {
            var matchedKeys = new List <string>();

            foreach (var end in _endPoints)
            {
                var server = Multiplexer.GetServer(end);
                if (key is null)
                {
                    // we get all key from database
                    foreach (var k in server.Keys(pattern: "*", database: Db.Database))
                    {
                        matchedKeys.Add(k);
                    }
                }
                else
                {
                    // we get specific key from database
                    foreach (var k in server.Keys(pattern: key.SearchKey, database: Db.Database))
                    {
                        matchedKeys.Add(k);
                    }
                }
            }
            return(matchedKeys);
        }
        public TValue GetValue(IRedisKey key)
        {
            var value = Db.StringGet(key.FullKey);

            if (value.IsNull)
            {
                return(default);
        /// <summary>
        /// Get matched key value by key from database.
        /// if key is null this will get all key value from database
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public Dictionary <string, TValue> GetKeyValues(IRedisKey key = null)
        {
            var dict = new Dictionary <string, TValue>();
            var keys = GetMatchedKeys(key);

            foreach (var k in keys)
            {
                dict.Add(k, JsonConvert.DeserializeObject <TValue>(Db.StringGet(k.ToString())));
            }
            return(dict);
        }
示例#4
0
 public void Dispose()
 {
     redisHash      = null;
     redisKey       = null;
     redisList      = null;
     redisLock      = null;
     redisSet       = null;
     redisSortedSet = null;
     redisStore     = null;
     redisString    = null;
     redisSubscribe = null;
 }
示例#5
0
 public IRedisKeyTests()
 {
     _provider = new StackExchangeRedisProvider(RedisConnStr);
 }
示例#6
0
 public IRedisKeyTests()
 {
     _provider = RedisFactory.GetProvider();
 }