Skip to content

Sqlite journal

Summary

Add sqlite journal

Background

A sqlite database might be a good place to store a cache item's metadata.

Details

Add a new implementation of interface Konecnyjakub\Cache\Common\Journal. Its constructor should take a PDO (or Pdo\Sqlite on PHP 8.4) instance which is connected to the sqlite database (if it is a different kind of database, an exception should be thrown). The constructor would also take care of creating all necessary tables if they do not exist.

The journal should work with 2 tables: 1 for tags and 1 for ttl as it should be usable with any kind of database so it needs to store both of those things. If the engine can handle ttl itself, it should still pass it to the journal even though it will not be used. The table for tags needs 2 columns, item key and a tag (one row should store only one tag for one item). The table for ttl needs 2 columns, item key and timestamp for expiration.

Follow-ups

We can consider making columns' names customizable. But it also can come later.