Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Key Search with Wildcards in NATS KV Methods #5540

Open
burl21 opened this issue Jun 15, 2024 · 6 comments
Open

Support for Key Search with Wildcards in NATS KV Methods #5540

burl21 opened this issue Jun 15, 2024 · 6 comments
Labels
proposal Enhancement idea or proposal stale This issue has had no activity in a while

Comments

@burl21
Copy link

burl21 commented Jun 15, 2024

Proposed change

I would like to request support for wildcard searches in the following NATS KV methods: ls and rm. This feature would enhance the flexibility and usability of NATS KV by allowing users to list and delete multiple keys that match a certain pattern.

Use case

In scenarios where multiple keys follow a naming pattern, such as cache entries, logs, or configuration settings, being able to fetch or remove them all with a single wildcard query would save time and reduce code complexity. This feature is particularly useful in large-scale applications where the number of keys can be substantial.

Consider a bucket named test with the following entries:

•	test.cache1
•	test.cache2

Using the ls and rm methods with a wildcard, such as nats kv ls test "test.*" or nats kv rm test "test.*", should list and delete both test.cache1 and test.cache2, respectively. This functionality is crucial for efficiently managing related key-value pairs without having to handle each key individually.

Contribution

No response

@burl21 burl21 added the proposal Enhancement idea or proposal label Jun 15, 2024
@derekcollison
Copy link
Member

The CLI ls is for buckets. However in the Go client, ListKeys can take a filter subject. Delete has no DeleteMulti at this point in time, but might be a good addition.

Not sure this is a server issues though. /cc @ripienaar and @piotrpio and @Jarema

@ripienaar
Copy link
Contributor

nats kv ls BUCKET for keys, I will add a subject filter.

@ripienaar
Copy link
Contributor

Actually, I do not see how ListKeys can take a filter - internally it always use WatchAll. We certainly could support that though.

@ripienaar
Copy link
Contributor

Since delete is a put in reality, I am reluctant to do a range as we cannot do that in an atomic manner today

@Jarema
Copy link
Member

Jarema commented Jun 20, 2024

Here is the ADR describing the new API in the clients: nats-io/nats-architecture-and-design#288

Clients will soon follow up with implementing them.
Here is the reference issue in Go client: nats-io/nats.go#1655

This does not include delete with wildcards, as that is a more complex story that requires server changes.

@Zetanova
Copy link

Zetanova commented Jul 4, 2024

I hade an idea to virtual-bucket that is related to this issue
#5204 (comment)

@github-actions github-actions bot added the stale This issue has had no activity in a while label Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Enhancement idea or proposal stale This issue has had no activity in a while
Projects
None yet
Development

No branches or pull requests

5 participants