9 Ağustos 2023 Çarşamba

SpringData Redis LettuceClientConfiguration Sınıfı

Giriş
Şu satırı dahil ederiz
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
readFrom metodu
Açıklaması şöyle. Okuma işleminin nerede yapılacağını belirtir.
All ReadFrom settings except MASTER may return stale data because replicas replication is asynchronous and requires some delay. You need to ensure that your application can tolerate stale data.

Setting                 Description 
MASTER                 Default mode. Read from the current master node.

MASTER_PREFERRED         Read from the master, but if it is unavailable, read from replica nodes.

REPLICA         Read from replica nodes.

REPLICA_PREFERRED        Read from the replica nodes, but if none is unavailable, read from the master.

LOWEST_LATENCY Read from any node of the cluster with the lowest latency.

ANY                         Read from any node of the cluster.

ANY_REPLICA         Read from any replica of the cluster.
Örnek
Şöyle yaparız
LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder()
    .commandTimeout(redisCommandTimeout)
    .readFrom(ReadFrom.REPLICA_PREFERRED)
    .build();

Hiç yorum yok:

Yorum Gönder