kvrocks icon indicating copy to clipboard operation
kvrocks copied to clipboard

Allow to delete keys by the prefix

Open Taymindis opened this issue 1 year ago • 5 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Motivation

  • Using Namespace in cluster mode to easily flush the keys .

Solution

  • As i knew namespace simply prepend the namespace prefix to the user key and remove it before retrieving. But it couldn't achieve with just simple key prefix.

we use the hash bracket like below, if our namespace is foo, and key is 1234, it will be successfully removed all the keys with same namespace. {foo}:1234

Are you willing to submit a PR?

  • [ ] I'm willing to submit a PR!

Taymindis avatar Oct 30 '24 00:10 Taymindis

@Taymindis Delete keys with the specified prefix would be easy in Kvrocks, but Redis now doesn't have a command for this and we need to invent one if we would like to support this. What do you think? @apache/kvrocks-committers

git-hulk avatar Oct 30 '24 01:10 git-hulk

As all keys are sorted by lexicographic order in kvrocks, maybe we can think of a set of commands about key prefix operation, of course, deleting keys by the prefix. oh scan already supports key pattern, but kvrocks is faster than expected

ShooterIT avatar Oct 30 '24 15:10 ShooterIT

oh scan already supports key pattern, but kvrocks is faster than expected

@ShooterIT Yes, another fast path is to use DeleteRange for the deletion command.

git-hulk avatar Oct 30 '24 15:10 git-hulk

Does it need to have a limit on the number of matches, similar to prefix matching?And it‘s just imple for keyType?

baobaomaomeng avatar Mar 19 '25 10:03 baobaomaomeng

Several questions:

  • It seems there's two PRs for this one task, so it's quite confusing. Are these two PRs competing with each other?
  • I think first we should define the semantics and command syntax of it. It will affect the performance of this command.

PragmaTwice avatar Mar 21 '25 10:03 PragmaTwice