I've thoroughly analyzed WP's cache, its functions and what it does and although simple in its design, it's effective: an object where you keep adding data that might be used somewhere else, so you don't hit the database.
Alright, but PHP is stateless. It remembers nothing between its sessions when talking about dynamic entities, so, every new request means a new lifecycle.
It's clearly not in the database. It also probably doesn't make sense to have a "globally shared" cache, because each user's variables might be different, so, if an user requests posts in a certain manner, another one most likely will request it in another manner (filters) and clearly, WordPress doesn't do it - it's not in the database either as a transient / option.
How does it happen, then?
Given that it's stateless, isn't the cache useless unless the same query was run twice? Because it dies on session close, a query ran before won't be there for you to retrieve its results for.
Edit:
I understand what __destruct
does, but in this case, the cache isn't saved nor in a session variable, nor in the user's cache, nor...nowhere, it just returns True
.