Cache invalidation
Cache invalidation deletes a cached key whenever a write path changes the underlying data represented by that key. The deletion should happen after the database transaction commits, rather than updating the cached value in place; TTL expiration provides a safety net for missed invalidations.
Minimal example
if err := tx.Commit(); err != nil {
return err
}
return rdb.Del(ctx, key).Err()