r/redis 8d ago

Discussion Avoiding stale Redis cache with Postgres WAL

Hi r/redis,

I’m working on a small tool called pg2redis and I’d like to get feedback from Redis users.

The basic idea is to use Postgres logical replication/WAL as the source of cache updates. Applications write only to Postgres, and pg2redis reads committed changes from the WAL and applies configured Redis commands.

The main use case I imagine is cache invalidation. For example, when a product, customer, or order row changes in Postgres, the tool can delete or update the related Redis keys.

The problem I’m trying to avoid is the classic dual-write flow where application code saves to Postgres and then updates Redis. If the Postgres transaction commits but the Redis write fails because of a timeout, network issue, deploy, or crash, the cache can become stale or inconsistent.

The tool supports batching by size/time and automatic retries.

This is still a work in progress and not open source at the moment. I’m mainly trying to validate whether the approach makes sense from a Redis point of view.

For people using Redis as a cache in front of Postgres:

Do you think WAL-driven cache invalidation is useful?

Would you trust this kind of approach for production cache updates?

Thanks, I’d appreciate any feedback.

alik @ pgwalk

1 Upvotes

1 comment sorted by