FIX: Always clear caches after committing the current transaction (#22491)

Instead of having to remember every time, just always wait until the
current transaction (if it exists) has committed before clearing any
DistributedCache.

The only exception to this is caches that aren't caching things from
postgres.

This means we have to do the test setup after setting the test
transaction, because doing the test setup involves clearing caches.
This commit is contained in:
Daniel Waterworth
2023-07-07 14:24:56 -05:00
committed by GitHub
parent b70bd4366b
commit 9dd01ca2ef
6 changed files with 24 additions and 17 deletions

View File

@ -19,4 +19,12 @@ class DistributedCache < MessageBus::DistributedCache
self.defer_set(k, value)
value
end
def clear(after_commit: true)
if after_commit
DB.after_commit { super() }
else
super()
end
end
end