我想知道有没有办法在redis-cli中使用" config get *"命令获取配置数据,并在c#控制台程序中查看它们。提前谢谢。
答案 0 :(得分:0)
我最近做了类似的事情,我正在为几种不同的统计类型捕获INFO。如果您使用的是StackExchange客户端,则IServer接口会公开一个名为ConfigGet()的方法,该方法允许您按名称请求特定的配置设置(或者在您的情况下,可能传入" *")。
这是一些示例代码(对不起它在VB中,这就是我在这个项目中使用的代码)
Public Sub Demo
Dim configurationString as String = "localhost:6379"
Dim options As ConfigurationOptions = ConfigurationOptions.Parse(configurationString)
options.AllowAdmin = true
Dim mu As ConnectionMultiplexer = ConnectionMultiplexer.Connect(options)
Dim server As IServer = mu.GetServer(configurationString)
Dim configSettings as KeyValuePair(Of String, String)() = server.ConfigGet("*")
For Each settingPair As KeyValuePair(Of String, String) In configSettings
Dim configurationKey as String = settingPair.Key
Dim configurationSetting as String = settingPair.Value
Console.WriteLine("Config {0} = {1}", configurationKey, configurationSetting)
Next
End Sub