undocumented parameters in libcouchbase_store
Hello,
I can't find any documentation that covers several of the parameters to libcouchbase_store. I've digged through the header files, but there are still some things that are unclear. Specifically:
- What are the possible
flags? - What's the
exptime in? Seconds from the epoch? Date in ISO format? - What is
casused for?
The full definition from couchbase.h is this:
LIBCOUCHBASE_API libcouchbase_error_t libcouchbase_store(libcouchbase_t instance, const void *command_cookie, libcouchbase_storage_t operation, const void *key, libcouchbase_size_t nkey, const void *bytes, libcouchbase_size_t nbytes, libcouchbase_uint32_t flags, libcouchbase_time_t exp, libcouchbase_cas_t cas);
Thanks!
@param flags the user-defined flag section for the item (doesn't have any meaning to Couchbase server)
does this mean flag can be used as some kind of "index" or "hash" for the key/value?
Yes, but keep in mind that some clients (like php, ruby, perl which are based on libcouchbase, or .net and java) use some bits of flags to mark the key type. For example ruby client uses 3 low bits.
Are the different clients compatible in their use of the flag section, or do they differ? Is the behavior something that we can rely on, or might it change in different version of clients, or between languages? I can think of many uses for it, but I don't want to worry that adding a new language client will clobber the data I already put in there.
Historically those flags came from memcached clients, therefore different clients are defining their own rules. Moreover some clients doesn't expose them to the user (like php client). What I've done for ruby client is to allow to fetch value without applying flag-sensitive transformations. For example if python client will set JSON value and arrange its own flag set to claim format, then the ruby client could ignore any flags and apply the JSON decoder.
doc = JSON.load(connection.get("foo", :format => :plain))
The code above share some knowledge about current application domain and the data in it. At least having this API will help to resolve flag-related issues in polyglot systems (from ruby side). Libcouchbase in this sense is pure library and doesn't touch the flags at all.
what about the cas parameter? I can't find any ways to get a cas value for a key?
Fixed already: https://github.com/couchbase/libcouchbase/blob/master/include/libcouchba...
Thanks
Find me on FreeNode IRC in #libcouchbase channel