dzhv.io
dzhv.io9mo ago

Is there a way to write a Deno.AtomicCheck that succeeds for any non-null versionstamp?

You can write a Deno.AtomicCheck that fails if the versionstamp for a key-value pair in the KV store does not match the given one. You can also write a Deno.AtomicCheck with a null versionstamp that fails if any key-value pair exists in the KV store. I need to write a Deno.AtomicCheck that fails if there is no existing key-value pair in the KV store. Is it possible to do this?
2 Replies
Deno AI Helper
Deno AI Helper9mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided, it seems like you're looking to create a sort of "existence check" for a key-value pair in a KV store using Deno's atomic operations. While I can't provide a direct answer from the documentation, I can suggest that if Deno's AtomicCheck API supports a check for the existence of a key-value pair, you might be able to use it in a way that it fails if the key-value pair does not exist. This would typically involve checking if the key has a non-null value or if the key itself is present in the store. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice. If Deno's AtomicCheck API does not support this functionality directly, you might need to implement a custom check or workaround to achieve the desired behavior.
cknight
cknight9mo ago
Not as a one step transaction. Your best bet is to first kv.get, capture the version stamp, manually validate it's not null then use it as a check in an atomic transaction.