How do I store a set in couchbase?

I have been using the Couchbase 1.0.0-beta python client and I'm getting great results so far!

That said, I am getting an exception when storing a set. how do I store a set in couchbase?

1 Answer

« Back to question.

The default storage format is JSON, and thus JSON has no way of representing a Python set().

To store a Python set, use the FMT_PICKLE storage format, which will store your object as pickle, like so:

cb.set("a_python_set", set([1,2,3]), format=couchbase.FMT_PICKLE)