Note: There appears to be a bug with the WordPress stats cache when you try to access the ‘postviews’ table with a post_id. The value is supposed to cache for 5 minutes, but it seems to stay cached indefinitely (I got frustrated after 4 hours of watching nothing move).
If you access the ‘postviews’ table with a query like this:
It’ll properly cache for 5 minutes. This gets stuck:
But it works if you set a random number of days since then you’re breaking the cache each time you access the data. We’re only doing this once an hour anyway (or whatever you set the delay to), so hacking this shouldn’t be an issue.
To test the arguments out and see what I’m talking about with the cache bug, use something like this: