Executing Redis Console commands in c#

≡放荡痞女 提交于 2020-05-28 03:28:58

问题


I need to get the "CLIENT LIST" output from redis console to be used in my c# application, is there a way to execute that command with the ConnectionMultiplexer? Or is there a built in method to find that information?


回答1:


CLIENT LIST is a "server" command, not a "database" command (as differentiated here), so you need to use IServer / GetServer() instead of IDatabase / GetDatabase(). The link shown also shows how to do this. Once you have that: there are ClientList and ClientListAsync methods that deal with all the parsing into a ClientInfo instance.

If it wasn't there, then the fallback options would be IDatabase.Execute[Async] (to issue an arbitrary raw command) or IDatabase.ScriptEvaluate[Async] (to issue Lua script).



来源:https://stackoverflow.com/questions/49029963/executing-redis-console-commands-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!