我的设置:
\n\n一切都很好,但我想知道读取操作是否可以始终首先尝试使用本地可用的 Redis 节点。这将大大提高性能,因为所有读取操作的跃点都会减少。
\n\n据我所知,可以通过命令标志属性将从站优先于主站 f\xc3\xbcr 特定命令。但有没有办法确定特定端点的优先级呢?
\n\n附:
\n\n使用的DLL:StackExchange.Redis.StrongName@1.2.0.0
\n\nRedis服务器版本:3.2.100
\n\n编辑:
\n\n这是我的连接代码。我没有使用推荐的 Lazy getter 的原因是因为我想在其中一个节点发生故障时进行连接/重新连接,这非常适合我的解决方案。
\n\ninternal class RedisConnector\n{\n private readonly ConfigurationOptions _currentConfiguration;\n internal ConnectionMultiplexer Connection;\n\n internal RedisCacheStore Store;\n\n internal RedisConnector(ConfigurationOptions configuration)\n {\n _currentConfiguration = configuration;\n Connect();\n }\n\n internal IDatabase Database\n => Connection.GetDatabase(RedisCacheConfiguration.Instance.Connection.DatabaseId);\n\n internal IServer Server => Connection.GetServer(Database.IdentifyEndpoint());\n\n private void Connect()\n {\n Connection = ConnectionMultiplexer.Connect(_currentConfiguration);\n …Run Code Online (Sandbox Code Playgroud)