1

I want to remove all keys matching SomePrefix* from my Redis. Is it possible ? I see only m_connectionMultiplexer.GetDatabase().KeyDelete() but not KeyMatch() or GetAllKeys() within the library.

Preferably not Lua scripting such as link by Leonid Beschastny

I want to use that on initialization of web application for development state of the application.

Community
  • 1
  • 1
eugeneK
  • 10,750
  • 19
  • 66
  • 101

1 Answers1

2

SE.Redis directly mimics the features exposed by the server. The server does not have a "delete keys matching this pattern" feature. It does have "scan for keys matching this pattern" (via GetServer().GetKeys(...)), and it has "delete this key / these keys" (via GetDatabase.KeyDelete(...)). You could iterate in batches over the matching keys, deleting each batch in turn. Because you can pipeline requests, you don't pay latency per batch.

As an alternative implementation: partition the data by numeric database (select) or server, and use flushdb / flush.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900