Created
April 11, 2020 00:19
-
-
Save itslukej/eb248ec2fa9ebd63b7df13510cc7cd28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local shard_id = tonumber(ARGV[3]) | |
| local shard_count = tonumber(ARGV[2]) | |
| local prefix = 'cache:' .. ARGV[1] .. ':' | |
| local keys = redis.call('keys', prefix .. '*') | |
| local deleted = 0 | |
| for i,v in pairs(keys) do | |
| local key = keys[i] | |
| local guild_id = string.sub(key, #prefix + 1) | |
| local guild_shard_id = math.floor((guild_id / 2^22) % shard_count) | |
| if shard_id == guild_shard_id then | |
| deleted = deleted + 1 | |
| redis.call('del', key) | |
| end | |
| end | |
| return deleted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment