RedisClient: RemoveByPattern

We are implementing a redis client towards a Azure Redis paas Service, and use RedisClient.RemoveByPattern()

According to https://stackoverflow.com/questions/34409963/removebypattern-method-is-not-available this uses Keys() internally, and that this should not be used in produciton. However I see in the sourcecode that the pattern is passed to the Keys method (https://github.com/ServiceStack/ServiceStack.Redis/blob/master/src/ServiceStack.Redis/RedisClient.cs)

Should I instead use the ScanAllKeys(yourPattern) as suggested in the stackoverflow post from 2015, or is the implementation fixed? We are using ServiceStack 5.5

Yeah you should ScanAllKeys if you intend to use it often and your dataset (i.e. number of keys) is very large as KEYS is blocking.

I’ve also just replace our internal usage of KEYS with ScanAllKeys in this commit so it uses the less server-blocking alternative at the expense of potentially more network requests.

If you want to use it now, this change is available from v5.6.1 that’s now available on MyGet.

Amazing - I will upgrade to 5.6.1 !

One other thing that would be great: Let IRedisClient extend IRemoveByPattern - then it will be easier to build tests and injecting a mock of IRedisClient to a component (currently I do a workaround by having a ICacheFake mockable Interface in our tests). This is not critical however:

No worries, IRemoveByPattern was added to IRedisClient added in this commit.

This change is available from the latest v5.6.1 on MyGet, if you already have v5.6.1 installed you’ll need to clear your NuGet packages cache.