Beispiel #1
0
        /// <summary>
        /// RedisValue[]转List对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="values"></param>
        /// <returns></returns>
        public static List <T> RedisValuesToList <T>(this IRedisStore redisStore, RedisValue[] values)
        {
            List <T> result = new List <T>();

            foreach (var item in values)
            {
                var model = redisStore.RedisValueToObject <T>(item);
                result.Add(model);
            }
            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// 获取站点信息
        /// </summary>
        /// <param name="mark"></param>
        /// <returns></returns>
        public async Task <WebSiteValue> GetAsync(int mark)
        {
            var key    = $"{_customPrefix}:{mark}";
            var number = _IRedisStore.GetRandomNumber(key);
            var result = await this._IRedisStore.Do(db => db.StringGetAsync(key), number);

            if (!result.HasValue)
            {
                return(default(WebSiteValue));
            }
            return(_IRedisStore.RedisValueToObject <WebSiteValue>(result));
        }
Beispiel #3
0
        /// <summary>
        /// 获取分类信息
        /// </summary>
        /// <param name="mark"></param>
        /// <returns></returns>
        public async Task <List <WebCategoryValue> > GetAsync(int mark)
        {
            var key    = $"{_IRedisStore.PrefixKey}:{mark}:categories";
            var number = _IRedisStore.GetRandomNumber(key);
            var result = await this._IRedisStore.Do(db => db.StringGetAsync(key), number);

            if (!result.HasValue)
            {
                return(new List <WebCategoryValue>());
            }
            return(_IRedisStore.RedisValueToObject <List <WebCategoryValue> >(result));
        }