Exemple #1
0
 /// <summary>
 /// 获取所有数据
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="keys"></param>
 /// <returns></returns>
 public static IDictionary <string, T> GetAll <T>(IEnumerable <string> keys) where T : class
 {
     using (IRedisClient redis = prcm.GetClient())
     {
         return(redis.GetAll <T>(keys));
     }
 }
Exemple #2
0
        public IDictionary <string, object> Get(params string[] keys)
        {
            IDictionary <string, object> result = null;

            try
            {
                bool flag = this.pool != null;
                if (flag)
                {
                    using (IRedisClient client = this.pool.GetClient())
                    {
                        bool flag2 = client != null;
                        if (flag2)
                        {
                            client.SendTimeout = 1000;
                            result             = client.GetAll <object>(keys);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string msg = string.Format("获取Redis缓存{0}失败,异常消息:{1},代码堆栈:{2}", keys, ex.Message, ex.StackTrace);
                RedisCacheManager.logger.Info(msg, new object[0]);
            }
            return(result);
        }
Exemple #3
0
 /// <summary>
 /// 获取keys集合中的一个值
 /// </summary>
 public IDictionary <string, T> Get <T>(List <string> keys)
 {
     using (IRedisClient Core = CreateRedisClient())
     {
         return(Core.GetAll <T>(keys));
     }
 }
Exemple #4
0
 /// <summary>
 /// 获取多个Key的值
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="keys"></param>
 /// <returns></returns>
 public IDictionary <string, T> GetAll <T>(IEnumerable <string> keys)
 {
     using (IRedisClient redisClient = RedisProvider.prcm.GetClient())
     {
         return(redisClient.GetAll <T>(keys));
     }
 }
Exemple #5
0
 public override IDictionary <string, T> GetAll <T>(string[] key)
 {
     using (IRedisClient redis = GetRedisClient())
     {
         return(redis.GetAll <T>(key));
     }
 }
Exemple #6
0
        public IEnumerable <StockDetail> GetAll()
        {
            var keys   = _redisClient.GetAllKeys();
            var result = _redisClient.GetAll <StockDetail>(keys);

            return(result.Values);
        }
Exemple #7
0
        public static void Main(string[] args)
        {
            // redis://clientid:password@localhost:6380?ssl=true&db=1
            var clientsManager = new BasicRedisClientManager("localhost:6379");

            try
            {
                _redisClient = clientsManager.GetClient();
                PrintCredentials();

                var valueMap = new Dictionary <string, string>();
                for (var i = 0; i < 100; i++)
                {
                    valueMap.Add($"key_{i}", $"value_{i}");
                }
                _redisClient.SetAll(valueMap);
                // _redisClient.RemoveAll(valueMap.Keys);

                Console.WriteLine("Getting all stored values");
                var values = _redisClient.GetAll <string>(valueMap.Keys);
                PrintDictionary(values);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #8
0
 /// <summary>
 /// 获取Keys内所有的值
 /// </summary>
 /// <typeparam name="T">类型</typeparam>
 /// <param name="keys">键</param>
 /// <returns></returns>
 public IDictionary <string, T> GetAll <T>(IEnumerable <string> keys)
 {
     lock (m_r)
     {
         return(m_r.GetAll <T>(keys));
     }
 }
Exemple #9
0
 /// <summary>
 ///     批量获取
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="keys"></param>
 /// <returns></returns>
 public static IDictionary<string, T> GetAll<T>(List<string> keys)
 {
     using (IRedisClient client = GetClient())
     {
         return client.GetAll<T>(keys);
     }
 }
Exemple #10
0
 /// <summary>
 /// 获取多个元素
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="key"></param>
 /// <returns></returns>
 public static IDictionary <string, T> MGet <T>(params string[] keys) where T : class
 {
     if (keys == null || keys.Length == 0)
     {
         return(new Dictionary <string, T>());
     }
     using (IRedisClient redis = prcm.GetClient())
     {
         return(redis.GetAll <T>(keys));
     }
 }
Exemple #11
0
        /// <summary>
        /// 获取多个键的值。
        /// </summary>
        /// <typeparam name="T">值的数据类型。</typeparam>
        /// <param name="keys">表示多个键的集合。</param>
        /// <returns></returns>
        public IDictionary <string, T> GetAll <T>(IEnumerable <string> keys, int index = 0)
        {
            IDictionary <string, T> all;

            using (IRedisClient readOnlyClient = base.pooledRedisClientManager.GetReadOnlyClient())
            {
                readOnlyClient.Db = index;
                all = readOnlyClient.GetAll <T>(keys);
            }
            return(all);
        }
        public KeyValuePair <string, string>[] GetAll(string webAppId)
        {
            using IRedisClient client = GetWebAppRedisClient(webAppId);
            var keys = client.GetAllKeys();

            if (keys == null || keys.IsEmpty())
            {
                return(new KeyValuePair <string, string> [0]);
            }
            return(client.GetAll <string>(client.GetAllKeys()).ToArray());
        }
Exemple #13
0
 /// <summary>
 /// 获取值 dic
 /// </summary>
 /// <typeparam name="T">泛型</typeparam>
 /// <param name="keys">键</param>
 /// <returns></returns>
 public IDictionary <string, T> GetDic <T>(string[] keys, int db = 0) where T : class, new()
 {
     try
     {
         Context.Db = db;
         return(Context.GetAll <T>(keys));
     }
     catch (RedisException ex)
     {
         SaveLog <T>(ex, "GetDic<T>");
         return(new Dictionary <string, T>());
     }
 }
Exemple #14
0
 /// <summary>
 /// 获取值 dic
 /// </summary>
 /// <typeparam name="T">泛型</typeparam>
 /// <param name="keys">键</param>
 /// <returns></returns>
 public static IDictionary <string, T> GetDic <T>(string[] keys, int db = 0) where T : class, new()
 {
     try
     {
         using (IRedisClient redis = Context(db).GetClient())
         {
             return(redis.GetAll <T>(keys));
         }
     }
     catch (RedisException ex)
     {
         SaveLog <T>(ex, "GetDic<T>");
         return(new Dictionary <string, T>());
     }
 }
        public static Dictionary <string, T> GetItems <T>(List <string> keys)
        {
            Dictionary <string, T> result;

            if (keys != null && keys.Count > 0)
            {
                using (IRedisClient client = GetClient())
                {
                    result = (Dictionary <string, T>)client.GetAll <T>(keys);
                    return(result);
                }
            }
            result = new Dictionary <string, T>();
            return(result);
        }
 /// <summary>
 /// Get all the elements with key using Key list
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="keys"></param>
 /// <returns></returns>
 public IDictionary <string, T> GetAll <T>(IEnumerable <string> keys)
 {
     try
     {
         using (IRedisClient redisClient = redismanager.GetClient())
         {
             return(redisClient.GetAll <T>(keys));
         }
     }
     catch (Exception e)
     {
         _logger.Error(e, "Error on GetALl ");
         throw;
     }
 }
Exemple #17
0
        //Permite Obtener la lista completa de datos almacenados en Redis
        public static List <Event> GetAll()
        {
            RedisConnection();
            var lstEvents = new List <Event>();
            var keys      = redisClient.GetAllKeys();

            if (keys != null && keys.Count() > 0)
            {
                var eventsResult = redisClient.GetAll <string>(keys);
                foreach (var @event in eventsResult)
                {
                    lstEvents.Add(JsonConvert.DeserializeObject <Event>(@event.Value));
                }
            }
            return(lstEvents);
        }