I'm making a game that uses redis to store game state. It keeps track of locations and players pretty well, but I don't have a good way to clean up inactive players.
Every time a player moves (it's a semi-slow moving game. Think 1-5 frames per second), I update a hash with the new location and remove the old location key.
What would be the best way to keep track of active players? I've thought of the following
- Set some key on the user to expire. Update every heartbeat or move. Problem is the locations are stored in a hash, so if the user key expires the player will still be in the same spot.
- Same, but use pub/sub to listen for the expiration and finish cleaning up (seems overly complicated)
- Store heartbeats in a sorted set, have a process run every X seconds to look for old players. Update score every heartbeat.
- Completely revamp the way I store locations so I can use expire.. somehow?
Any other ideas?