Ejemplo n.º 1
0
        public async Task <SortedSetEntry[]> GetDays(string key, Tuple <DateTime, int, int> tuple)
        {
            var number = _IRedisStore.GetRandomNumber(key);

            key = $"{key}:{tuple.Item1.ToString("yyyyMMdd")}";
            return(await _IRedisStore.Do(db => db.SortedSetRangeByRankWithScoresAsync(key, tuple.Item2, tuple.Item3, Order.Descending), number));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 停用 Token
        /// </summary>
        /// <param name="token">Token</param>
        /// <returns></returns>
        public async Task <bool> DeactivateAsync(string token)
        {
            var tokenKey = GetKey(token);
            var number   = _IRedisStore.GetRandomNumber(tokenKey);

            //var d = new DistributedCacheEntryOptions {
            //    AbsoluteExpirationRelativeToNow =
            //        TimeSpan.FromMinutes(Convert.ToDouble(_configuration["Jwt:ExpireMinutes"]))
            //};
            return(await _IRedisStore.Do(db => db.StringSetAsync(tokenKey,
                                                                 token,
                                                                 TimeSpan.FromMilliseconds(1)
                                                                 ), number));
        }
Ejemplo n.º 3
0
        public async Task <Tuple <bool, bool> > AddAccessCount(int mark)
        {
            ///当前日期
            var day = System.DateTime.Now.ToString("yyyyMMdd");

            var key      = $"{_customPrefix}:access";
            var countKey = $"{_customPrefix}:access:all";

            var accessNumber = _IRedisStore.GetRandomNumber(key);
            var countNumber  = _IRedisStore.GetRandomNumber(countKey);

            // 日访问Key
            key = $"{key}:{day}";
            // SortSet日访问排行数据(+1)
            var dayResult = await _IRedisStore.Do(db => db.SortedSetIncrementAsync(key, mark, 1), accessNumber);

            // SortSet总访问排行数据(+1)
            var allResult = await _IRedisStore.Do(db => db.SortedSetIncrementAsync(countKey, mark, 1), countNumber);

            return(new Tuple <bool, bool>(dayResult > 0, allResult > 0));
        }
Ejemplo n.º 4
0
        public async Task <bool> AddClickCount(int mark, string id)
        {
            var flag = false;

            var day = System.DateTime.Now.ToString("yyyyMMdd");// 当前日期

            var key    = $"{_IRedisStore.PrefixKey}:{mark}:news:click";
            var number = _IRedisStore.GetRandomNumber(key);
            // 日点击key
            var daykey = $"{key}:{day}";
            // SortSet日点击排行数据(+1)
            var result = await _IRedisStore.Do(db => db.SortedSetIncrementAsync(daykey, id, 1), number);

            if (result > 0)
            {
                flag = true;
            }
            else
            {
                flag = false;
            }
            return(flag);
        }