I am newbie in redis, Now I want get all keys in one db without knowing about keys or pattern of keys. After googling,I found a sodu code about my issue, but i have no key pattern or data field in this code:
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);
Redis GET all Keys To list the keys in the Redis data store, use the KEYS command followed by a specific pattern. Redis will search the keys for all the keys matching the specified pattern. In our example, we can use an asterisk (*) to match all the keys in the data store to get all the keys.
It uses Lazy<T> to handle thread-safe initialization. It sets "abortConnect=false", which means if the initial connect attempt fails, the ConnectionMultiplexer will silently retry in the background rather than throw an exception.
The central object in StackExchange. Redis is the ConnectionMultiplexer class in the StackExchange. Redis namespace; this is the object that hides away the details of multiple servers. Because the ConnectionMultiplexer does a lot, it is designed to be shared and reused between callers.
Redis Keys are Ideal for Keeping Track of Lots of Strings. For the (simple string) key-value data type Redis allows you to set, get, delete, and increment arbitrary string <key, value> pairs. You can only have 1 value at a time for each key (i.e. set is destructive assignment). You can also delete keys.
According to this link, the following code gets all the keys:
var keys = myCacheClient.SearchKeys("*");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With