Rails’ query cache will happily cache your advisory lock
If you take a PostgreSQL advisory lock with select_value, Rails might answer from its query cache instead of asking the database. Here’s how that breaks your lock, and how to avoid it.
Notes on things I’ve built, debugged, or learned along the way, newest first.
If you take a PostgreSQL advisory lock with select_value, Rails might answer from its query cache instead of asking the database. Here’s how that breaks your lock, and how to avoid it.
SQL injection is a well-known threat, but NoSQL databases like MongoDB can be injected too. A look at how it happens, and how to protect your queries.
Memoization doesn’t always stop effects from rerunning. Here’s a lesser-known pattern that uses refs to stop effects from rerunning when they don’t need to.