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

Implement multiple cache gets #14

Closed spacedmonkey closed 1 year ago

spacedmonkey commented 1 year ago

Currently the multiple get, just loops around the keys and gets each key at the time. See

https://github.com/OllieJones/sqlite-object-cache/blob/898ed2d2aae778fab24b1cf1f2a464f111791578/assets/drop-in/object-cache.php#L1460-L1468

There this works, it is not the best for performance. If a single database call can be done to get all cache keys at once.

OllieJones commented 1 year ago

Implementing the whatever_multiple operations is an interesting challenge in SQLite. In client-server cache systems it makes sense to pipeline all the requests to and from the server. But in SQLite an operation like

SELECT what,ever FROM object_cache WHERE name ('default|this', 'default|that', 'default|theOtherThing' )

just does three index lookups, as do three consecutive SELECTs. The queries are prepared statements in any case.

I added transaction semantics around the multiples; that saves time on the multiple updates.