简体   繁体   中英

Lettuce Redis library strong consistency using ReadFrom

In my service I am trying to ensure strong consistency using ReadFrom method of Lettuce client. I am writing and then performing a read. In the client configuration, I have set ReadFrom to SLAVE_PREFFERED . Lettuce documentation says in SLAVE_PREFFERED , "Read from the replica nodes, but if none is unavailable, read from the master.".

I want to know, does the Lettuce client only reads from master, if none of the read replicas are available?

What if read replicas are available but none of the replicas have the key? Does it read from the master then?

I want to know, does the Lettuce client only reads from master, if none of the read replicas are available?

Yes, that's what happens.

ReadFrom instructs Lettuce to use a specific selection of nodes to issue a particular read command.

What if read replicas are available but none of the replicas have the key?

Then you get the a not found-like response. Eg GET results in a null value.

Does it read from the master then?

No. Commands are issued only once. ReadFrom provides command routing.

If you want strong consistency, then you only read from master nodes. Reading from non-master nodes results in eventual consistency.

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