Couchbase: python SDK "uppend" -


i want "uppend_multi": append_multi (http://pythonhosted.org/couchbase/api/couchbase.html#couchbase.bucket.bucket.append_multi) of keys may not exist. if not exist append operation should insert. how can this? nothing in api docs suggests supported, imagine common operation.

right doing this, seems natural of thing need highly doubt best way it:

def _uppend_multi(bucket, append_dict):     reinsert_dict = {}     try:         bucket.append_multi(append_dict, format = couchbase.fmt_utf8)      except couchbaseerror exc:         k, res in exc.all_results.items():             if res.success:                 pass             else:                 reinsert_dict[k] = append_dict[k]      if len(reinsert_dict.keys()) > 0:         bucket.insert_multi(reinsert_dict, format = couchbase.fmt_utf8) 

as far know there no such "uppend" operation in couchbase python sdk, nor in lower-level c api (libcouchbase).

what you're doing pretty reasonable solution.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -