StackExchange.Redis how to query all db Keys
stackexchange.redis
Solution
Firstly, what redis server version are you using? The server commands available varies between servers, and on versions before 2.8 the `KEYS` command must be used instead of the `SCAN` command. The `KEYS` command is well known for causing major performance problems and should never be used in production, except perhaps on a slave. If you are using < 2.8, yes I would expect `KEYS` to cause timeouts.
However, ultimately both `SCAN` and `KEYS` suggest that you aren't using redis in the intended way. You should not ever find yourself needing to use those commands for regular operations. The only tools that should use them routinely are admin / data exploration tools. And they should ideally target slaves, not masters.
There are usually alternative ways to do anything that people tend to want `SCAN` and `KEYS` for - for example, by storing the keys in a particular group in a single set (`SADD` etc)
Problem
I'm trying to find some Keys that follow a pattern, but I need all related keys not just the ones in a specific server. Until now I'm trying to access a specific server using documentation example, but it doesn't work. ``` var connection = ConnectionMultiplexer.Connect(new ConfigurationOptions { EndPoints = { { DemoSettings.CustomerRedisCache.Url, DemoSettings.CustomerRedisCache.Port } }, Password = DemoSettings.CustomerRedisCache.Password }); var server = connection.GetServer(host: DemoSettings.CustomerRedisCache.Url, port: DemoSettings.CustomerRedisCache.Port); var cadena = "cust:" + data.SearchString.Replace(' ', ':')+"*"; var valores = server.Keys(pattern: cadena); ``` Last line always fail because of a timeout :S I'll appreciate any help.