简体   繁体   中英

Is the Symfony Redis Cache adapter using atomic transactions by default?

I'm trying to deploy a distributed service architecture using Symfony.

My question is if I can rely on the Redis Cache adapter to read/write in an atomic matter? If a service needs to register itself in the serialized services array, no other service should try to register itself in the meantime given it will delete the initial service from the array.

Should I use the Symfony Lock to avoid race conditions on the same cache key?

Stack: php8.0, php-redis8.0

Yes, Symfony Lock is useful in this case. You can avoid race condition by using lock on same cache key or database operation. Just keep in mind once you have acquire lock then don't forget to release it:)

In case, if you want document then here is the link: https://symfony.com/doc/current/components/lock.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM