iCantSneed / mati-superchats

MATI superchats archiver
https://mati.x10.mx
GNU Affero General Public License v3.0
0 stars 0 forks source link

Cache desync #76

Closed iCantSneed closed 1 month ago

iCantSneed commented 1 month ago

Observed on dev only for now, need to investigate if it occurs on prod as well.

Incoming superchats should be cached on both APCu and filesystem. From observation, they do get cached on the filesystem, but it's unclear as to if it gets cached on APCu. Navigating to the /live endpoint retrieves superchats from the APCu cache, but it retrieves stale info for whatever reason.

Furthermore, disabling the filesystem cache breaks the app. SimplePie requires the filesystem cache, otherwise it'll attempt to write its own cache, which is undesirable.

iCantSneed commented 1 month ago

From https://symfony.com/doc/current/components/cache/adapters/apcu_adapter.html:

This adapter's CRUD operations are specific to the PHP SAPI it is running under. This means cache operations (such as additions, deletions, etc) using the CLI will not be available under the FPM or CGI SAPIs.

Storing superchats is done by the CLI and retrieving is done by CGI (or whatever that's not CLI), and since they're using different storages, the web's APCu cache will always be stale. Therefore, using APCu just won't work, and some other fast cache should be used, or just use filesystem cache exclusively.