List keys | Cloudflare Workers KV

Hi all, when I am using list method and cursor for pagination (https://developers.cloudflare.com/kv/api/list-keys/#list-method). What happens if I have 1 milion keys and when I get a page I trigger delete of that keys and then use cursor to go to the second page? Would cursor have an old list so it will continue serving correct pages even though that I am deleting keys in the background?
Cloudflare Docs
List keys | Cloudflare Workers KV
To list all the keys in your KV namespace, call the list() method of the KV binding on any KV namespace you have bound to your Worker code:
3 Replies
thomasgauvin
thomasgauvin4mo ago
The eventual consistency model of KV means you can't rely on the list operation to return only undeleted information. The recommendation here would be to keep track of which are deleted vs not
nejc
nejcOP4mo ago
how can I know if they are deleted or not? from list operation
thomasgauvin
thomasgauvin4mo ago
The eventual consistency nature of KV means that you cannot reliably rely on the API to indicate whether it's been deleted or not because it may not have been propagated immediately. You would need to store the status of whether the deletion was successful or not and keep your own consistent store. What are you trying to do here? A binding might be a better path in case you expect to have high throughput which may hit REST API rate limits
Want results from more Discord servers?
Add your server