简体   繁体   中英

How to make sure only one Instances is putting data into Redis Caching server during pre-load process

I am using CacheManager for Redis connections.

Right now, I have multiple instances running same application and connect to same Redis server.

At 8:00, application will be scheduled to do preload method to load data by using put into Redis server.

How do I make sure only one of them is writing to Redis?

Do I use lock or something else able to make that happen?

You can use Redis String as a distribute lock. see more in: https://redis.io/topics/distlock

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