shinypb / openkeyval

OpenKeyval.org is a completely open key-value data store, exposed as a drop-dead simple web service. The goal is to make this a very easy way to persist data in web applications.
http://openkeyval.org
Other
137 stars 35 forks source link

When setting value, indicate whether key already existed in response #19

Open johtso opened 13 years ago

johtso commented 13 years ago

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\/"
}
dustball commented 13 years ago

Yes, this seems reasonable.

RomainMuller commented 12 years ago

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.