2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2026-05-03 19:50:27 +00:00

Introduce a set of performance tweaks.

The most notable changes are a refactor of DataManager to make the caching system easier to tweak, and the ability to use Lua scripts that run on the Redis server to optimize certain batch operations (currently, only getServersToPlayers() uses this).

This also paves the way for me to deprecate old versions of Redis. Anything older than 2.6 is ancient, and even 2.6 is ancient, so it ends up being a net overall benefit.
This commit is contained in:
Tux
2015-06-21 17:32:28 -04:00
parent 27bf52f13d
commit 8b5eacec40
7 changed files with 321 additions and 114 deletions

View File

@@ -0,0 +1,20 @@
-- This script needs all active proxies available specified as args.
local serverToData = {}
for _, proxy in ipairs(ARGV) do
local players = redis.call("SMEMBERS", "proxy:" .. proxy .. ":usersOnline")
for _, player in ipairs(players) do
local server = redis.call("HGET", "player:" .. player, "server")
if server then
if serverToData[server] then
local data = serverToData[server]
data[#data + 1] = player
else
serverToData[server] = {player}
end
end
end
end
-- Redis can't map a Lua table back, so we have to send it as JSON.
return cjson.encode(serverToData)