OllieJones / sqlite-object-cache

A WordPress persistent object cache for the rest of us.
GNU General Public License v2.0
24 stars 4 forks source link

Cache gets too big on some sites #31

Closed OllieJones closed 1 year ago

OllieJones commented 1 year ago

On some sites the cache grows without bound.

It's possible these sites have problems with invoking the hourly WP_Cron job needed to handle the situation.

Proposed fix: Immediately before close, with a probability of 1/2000 or so, do the following in a transaction.

  1. Measure the cache size.
  2. If it is larger than 1.25 * target size...
  3. Purge least-recently-updated entries to bring it to target size.

This should keep the size under control at a reasonable operational cost without relying critically on WP_Cron.

The WP_Cron job will stay in place.