I’m thinking about how to write an application cache. This could be thought of as a way of replicating a moderate amount of data from a table, without doing something heavy like replicating the entire database.
Although it’s not officially supported, Postgres listen/notify does work, provided that you use a direct connection. However, when the database shuts down, the connection is lost.
That’s okay because the database can’t change while it’s shut down. The data in the cache is up to date, until the database starts up again and someone makes a change.
So, it would be good to have a way to register a webhook that’s called whenever the database starts up.
Workarounds:
Perhaps this could be done with the admin API? But I’m wary because I don’t see a way to restrict permissions.
I guess I could try using Polyscale, but it’s not clear to me how their cache invalidation works. Do they assume all database access goes through Polyscale?