Skip to content

Implement local DB cache with BBolt

Jack Henschel requested to merge db-cache into dev

As described in #10 (closed) , we want to have local cache of all entries such that the application (at least redirections) stay available even when something happens to the database.

To achieve this, I implemented two things (separate commits):

  1. An efficient mechanism that allows us to subscribe to changes that are happening in the database. For PostgreSQL, this is done with a trigger that gets executed whenever there are changes in the redirections table. This trigger then pushed a notification using Postgres' LISTEN/NOTIFY mechanism.

  2. A local cache (effectively another database) that "materializes" the redirections locally (but only the information needed to serve the redirect, not other info like owner, description etc.) This is implemented with BBolt, the key-value store that underlies etcd.

I hope I also left enough comments and references in the code, if not please point out where things are unclear :-)

Closes #10 (closed)

Edited by Jack Henschel

Merge request reports