A server with thousands of saved players runs out of memory loading all of them
Most saved characters belong to people who are not playing right now. Here is a small cache that keeps the ones who are present, lets the others leave when space is needed, and never throws away a change that was not written yet.
Why this works
Memory is limited, but attention is too: most saved players are not here and will not be soon. Keeping the ones in use and dropping the longest unused is a good guess about who returns next. Writing before dropping keeps the last change.
When not to use it
Do not bother when the world is small, say a few dozen friends: everything fits in memory and the extra rules only add chances for mistakes. It also hurts when many players return in waves, as the cache keeps reloading the same ones.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 4 common mistakes and the fix
- A diagram of every state
- 25 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "A server with thousands of saved players runs out of memory loading all of them" (read_entry load-only-who-is-here) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP