public
Last active

couchbase perf tests

  • Download Gist
test_add_cb.py
Python
1 2 3 4 5 6 7 8 9 10 11
from couchbase.client import Couchbase
 
 
def insert_doc():
couchbase = Couchbase("localhost:8091", "account", "")
bucket = couchbase["account"]
key = "test_key"
val = "test_val"
bucket.set(key, 0, 0, val)
 
insert_doc()
test_add_rest.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
import httplib2
import json
 
 
def insert_doc():
http = httplib2.Http()
http.add_credentials("Administrator", "password")
doc_name = "mydoc"
url = 'http://127.0.0.1:8092/account/%s' % doc_name
doc = {"doc_foo": "foo", "doc_bar": "bar"}
body = json.dumps(doc, sort_keys=True, indent=4)
response, content = http.request(
url,
'PUT',
body,
headers={'Content-type': 'application/json'}
)
 
insert_doc()
test_get_cb.py
Python
1 2 3 4 5 6 7 8 9
from couchbase.client import Couchbase
 
 
def get_doc():
couchbase = Couchbase("localhost:8091", "account", "")
bucket = couchbase["account"]
bucket.get("test_key")
 
get_doc()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.