多活高可用服务 MAS-Jedis、Lettuce

时间:2024-10-23 17:37:41

Jedis、Lettuce

直接替换客户端。
import com.huawei.devspore.mas.Redis.adapter.model.SetParams;
import com.huawei.devspore.mas.Redis.core.MultiZoneClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DemoService{
    @Autowired
    private MultiZoneClient client;
    public void set() {
        client.set("lock", "", SetParams.builder().hasNx(true).ex(30L).build());
    }
}
support.huaweicloud.com/devg-mas/mas-devg-00113.html