.affinity cooldown will now work properly on multiple shards

This commit is contained in:
Master Kwoth
2017-11-03 12:35:27 +01:00
parent 30a609f9a6
commit 0dbd60b5ac
3 changed files with 19 additions and 16 deletions

View File

@ -83,5 +83,18 @@ namespace NadekoBot.Core.Services.Impl
_db.KeyDelete(k, CommandFlags.FireAndForget);
}
}
public bool TryAddAffinityCooldown(ulong userId, out TimeSpan? time)
{
time = _db.KeyTimeToLive($"{_redisKey}_affinity_{userId}");
if (time == null)
{
time = TimeSpan.FromMinutes(30);
_db.StringSet($"{_redisKey}_affinity_{userId}", true);
_db.KeyExpire($"{_redisKey}_affinity_{userId}", time);
return true;
}
return false;
}
}
}