[英]How to SET on specific redis server with StackExchange.Redis client?
I have 3 redis servers running in docker containers. 我有3个Redis服务器在Docker容器中运行。 From redis-cli I can SET on specific server.
从redis-cli可以在特定服务器上进行设置。
SET myValue 100
How can I do this with StackExchange.Redis client? 如何使用StackExchange.Redis客户端执行此操作?
I don't see anything in server api that allows to do that. 我在服务器api中看不到任何允许执行此操作的操作。 Bear in mind that I don't know much about Redis at all.
请记住,我对Redis并不了解。
var connection = ConnectionMultiplexer.Connect("localhost:6379,localhost:6380,localhost:6381");
var server = connection.GetServer("localhost", 6381);
server.???
SE.Redis expects to be managing a single logical keyspace; SE.Redis希望管理一个逻辑键空间。 the support for multiple nodes is intended either for master/replica setups, or for redis-cluster (although, in the case of cluster, node discovery is achieved via the redis API, so a single node would be fine if it is reachable).
对多个节点的支持既可以用于主/副本设置,也可以用于redis-cluster(尽管在集群的情况下,可以通过redis API实现节点发现,因此如果单个节点可以访问,则可以)。 With that in place: the selection of servers is implicit from the operation (ie writes need to go to a master, and in the case of "cluster", the keyspace shard mapping should be applied).
这样就可以了:服务器的选择在操作中是隐含的(即,写入需要转到主服务器,在“集群”的情况下,应应用键空间分片映射)。
If you want to write to separate servers as though they are separate databases , you should use a connection per server; 如果要像写入单独的服务器一样将它们写入单独的数据库中 ,则应为每个服务器使用一个连接; not a single connection that spans them all.
没有一个跨越所有领域的连接。 Right now, SE.Redis is probably detecting 3 master nodes and electing to use one of them arbitrarily.
目前,SE.Redis可能正在检测3个主节点并选择任意使用其中一个。 You can see what it thinks by passing a
TextWriter
to the Connect
/ ConnectAsync
method. 您可以通过将
TextWriter
传递给Connect
/ ConnectAsync
方法来查看其想法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.