Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current  |   View Page History

Proposed Python SDK API

This is about designing the API for the next generation Python SDK for Couchbase. In the end the API might look the same as the current one, or be completely different. Feel free to come up with any ideas.

To make it easier to get a feeling on what the API might look like I'll list a few API calls from different SDKs.

"Python" describes the current API, "Python vmx" is what Volker Mische has in mind. Add your own ideas, leave comments or sent an email to the Couchbase Group.

Connect to a bucket

The Python has the concept of a Server Connection where you can select buckets from. In the Ruby and PHP you connect directly to a bucket.

Python

couchbase = Couchbase(ip:port, username, password)
bucket = couchbase[bucketname]

Python vmx

Get rid of the server and buckets concept, and connect directly to a bucket.

cb = Couchbase(ip:port, username, password, bucket)

Ruby

In Ruby there are essentially two ways, with a string to the REST end-point of a bucket, or with a hash.

c = Couchbase.connect(rest-end-point-of-a-bucket)
c = Couchbase.connect(:hostname, :port, :bucket, :username, :password)

PHP

$cb = new Couchbase(ip:port, username, password, bucketname);

Get

SDK get multi-get get-and-touch
Python bucket.get(key) or
bucket[key]
- bucket.gat(key, expiry)
Python vmx cb.get(key) or
cb[key]
cb.get(array-of-keys) cb.get(key, ttl=ttl)
Ruby c.get(key) or
c[key]
c.get(key1, key2, key3, ...) c.get(key, :ttl=ttl)
PHP $cb->get(key) $cb->getMulti(array-of-keys) cb->getAndTouch(key, expiry)

Set

SDK set value set value with expiration multi-set
Python bucket.set(key, expiration, flags, value) or
bucket[key] = value
bucket.set(key, expiration, flags, value) or
bucket[key] =
Unknown macro: {'value'}

-
Python vmx cb.set(key, value) or
cb[key] = value
cb.set(key, value, ttl=ttl) cb.set(
Unknown macro: {key1}

)

Ruby c.set(key, value) or
c[key] = value
c.set(key, value, :ttl=ttl) c.set(key1 => value1, key2 => value2, ...)
PHP $cb->set(key, value) $cb->set(key, value, expiry) $cb->setMulti(array-of-key-value-pairs)
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.