Example #1
0
        /// <summary>
        /// 获取
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        public TEntity Get <TEntity>(string key)
        {
            var value = redisConnection.GetDatabase().StringGet(key);

            if (value.HasValue)
            {
                //需要用的反序列化,将Redis存储的Byte[],进行反序列化
                return(SerializeUtil.ByteArrayDeserialize <TEntity>(value));
            }
            else
            {
                return(default(TEntity));
            }
        }