public async Task <IEnumerable <long> > GetInviter(string platform)
        {
            var allInviter = await RedisOpt.GetZsetAllKeyAsync(KeyGenTool.GenKey
                                                                   (platform, "Invited"));

            return(allInviter.Select(x => long.Parse(x)));
        }
        public Task RemovInviteFriend(IEnumerable <long> allInviter, string platform)
        {
            List <Task> allTasks = new List <Task>
            {
                RedisOpt.DeleteKeyAsync(KeyGenTool.GenKey
                                            (platform, "Invited"))
            };

            foreach (var oneInviter in allInviter)
            {
                allTasks.Add(RedisOpt.DeleteZsetValueAsync(KeyGenTool.GenUserKey
                                                               (oneInviter, "Inviter"), platform));
            }
            return(Task.WhenAll(allTasks));
        }
        public async Task SetInviteFriend(long id, string platform)
        {
            string keyInvited = KeyGenTool.GenKey(platform, "Invited");
            string keyInviter = KeyGenTool.GenUserKey(id, "Inviter");
            var    t1         = RedisOpt.AddZsetValueAsync(keyInvited, id.ToString(),
                                                           DateTime.Now.ToTimeStamp());
            var t2 = RedisOpt.AddZsetValueAsync(keyInviter, platform,
                                                DateTime.Now.ToTimeStamp());
            await Task.WhenAll(t1, t2);

            var t3 = RedisOpt.ExpiryAsync(keyInvited, TimeSpan.FromDays(30));
            var t4 = RedisOpt.ExpiryAsync(keyInviter, TimeSpan.FromDays(30));
            var t5 = RedisOpt.DeleteZsetValueRangeAsync(keyInvited, 0, DateTime.Now.ToTimeStamp() - TimeSpan.FromDays(30).TotalSeconds);
            var t6 = RedisOpt.DeleteZsetValueRangeAsync(keyInviter, 0, DateTime.Now.ToTimeStamp() - TimeSpan.FromDays(30).TotalSeconds);
            await Task.WhenAll(t3, t4, t5, t6);
        }
Ejemplo n.º 4
0
 public Task SetLoginCheckInfo(string account, AccountInfo info)
 {
     return(RedisOpt.SetStringAsync(KeyGenTool.GenKey(account, nameof(LoginCheckInfo)),
                                    new LoginCheckInfo(info.Id, info.PlatformAccount, info.Type),
                                    TimeSpan.FromDays(7)));
 }
Ejemplo n.º 5
0
 public Task <LoginCheckInfo> GetLoginCheckInfo(string platformAccount)
 {
     return(RedisOpt.GetStringAsync <LoginCheckInfo>(KeyGenTool.GenKey(platformAccount,
                                                                       nameof(LoginCheckInfo))));
 }