예제 #1
0
        /// <summary>
        /// 存储数据到hash表
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="dataKey"></param>
        /// <param name="t"></param>
        /// <param name="second">秒</param>
        /// <returns></returns>
        public bool HashSet <T>(string key, string dataKey, T t, long second = -1)
        {
            string value  = CsRedisHelper.HashSet(key, GetExpire(second), dataKey, ConvertJson <T>(t));
            bool   result = string.Equals(value, "OK",
                                          StringComparison.OrdinalIgnoreCase);

            return(result);
        }
예제 #2
0
        /// <summary>
        ///  存储数据到hash表
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="kvalues"></param>
        /// <param name="second">秒</param>
        /// <returns></returns>
        public bool HashSet <T>(string key, Dictionary <string, T> kvalues, long second = -1)
        {
            List <object> keyValues = new List <object>();

            foreach (var kvp in kvalues)
            {
                keyValues.Add(kvp.Key);
                keyValues.Add(ConvertJson <T>(kvp.Value));
            }

            return(string.Equals(CsRedisHelper.HashSet(key, GetExpire(second), keyValues.ToArray()), "OK",
                                 StringComparison.OrdinalIgnoreCase));
        }