Ruby on Rails - is a cache transaction safe?

Will it work with the problem of updating two users?

I googled and looked in the api but found nothing

Rails 3+, ruby ​​1.9.3

+5
source share
2 answers

When using counter_cache, writing and updating the counter are performed in one transaction. But this does not guarantee the atomicity of the operation. You may need to “lock” your account to avoid problems updating two users.

See this great article . This is about the redis-objects stone, but the first two parts perfectly explain the problem and solution using ActiveRecord.

+2
source

: . , Rails counter_cache , , , , , , , , with_lock .

+1

All Articles