/// <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)); }
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)); }
public async Task <Tuple <bool, bool> > AddAccessCount(int mark, string id) { ///当前日期 var day = System.DateTime.Now.ToString("yyyyMMdd"); var accessKey = $"{_IRedisStore.PrefixKey}:{mark}:channel:access"; var countKey = $"{_IRedisStore.PrefixKey}:{mark}:channel:access:all"; var accessNumber = _IRedisStore.GetRandomNumber(accessKey); var countNumber = _IRedisStore.GetRandomNumber(countKey); // 日访key accessKey = $"{accessKey}:{day}"; // SortSet日访问排行数据(+1) var dayResult = await _IRedisStore.Do(db => db.SortedSetIncrementAsync(accessKey, id, 1), accessNumber); var allResult = await _IRedisStore.Do(db => db.SortedSetIncrementAsync(countKey, id, 1), countNumber); return(new Tuple <bool, bool>(dayResult > 0, allResult > 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); }