openkeyval icon indicating copy to clipboard operation
openkeyval copied to clipboard

When setting value, indicate whether key already existed in response

Open johtso opened this issue 13 years ago • 2 comments

This would allow you to have something like a lock file that multiple clients could share.

Without knowing if the key already existed when writing, someone else could have written to the lock file in the time between you last checking if it existed, and writing to it.

Would this be useful?

Something like:

{
   "status":"multiset",
   "keys":[
      {
         "key":"testing1",
         "read_only_key":"rok-459f1694e2455461b1186749aaf3f949eba8a134",
         "new":"true"
      },
      {
         "key":"testing2",
         "read_only_key":"rok-ee9efec3c53f048a34dba2b923ddbdaa8693aead",
         "new":"false"
      }
   ],
   "documentation_url":"http:\/\/openkeyval.org\/"
}

johtso avatar Jun 12 '11 19:06 johtso

Yes, this seems reasonable.

dustball avatar Jun 13 '11 19:06 dustball

That would indeed be very useful. Alternatively, providing a way to write-if-not-exists, that could possibly be extended to write-unless-newer-than would bridge the gap as well.

RomainMuller avatar May 09 '12 13:05 RomainMuller