Skip to content

Instantly share code, notes, and snippets.

@abhi-bit
Created October 8, 2014 09:29
Show Gist options
  • Save abhi-bit/d478e251c81744201910 to your computer and use it in GitHub Desktop.
Save abhi-bit/d478e251c81744201910 to your computer and use it in GitHub Desktop.
Check if append allows to store 20MB+ blobs in Couchbase
# Usage:
# python data.py <cluster-ip> <bucket>
from couchbase import Couchbase
from couchbase import FMT_BYTES
from random import choice
from string import lowercase
import sys
TIMES_TO_APPEND = 1626
BLOCK_SIZE = 10000
def main():
host = sys.argv[1]
bucket = sys.argv[2]
cb = Couchbase.connect(bucket=bucket, host=host)
key = "pymc0"
value_to_append = "".join(choice(lowercase) for _ in range(BLOCK_SIZE))
try:
cb.delete(key)
except:
print "key doesn't exist"
cb.set(key, "orig", format=FMT_BYTES)
print sys.getsizeof(cb.get(key).value)
for _ in xrange(TIMES_TO_APPEND):
cb.append(key, value_to_append, format=FMT_BYTES)
print sys.getsizeof(cb.get(key, no_format=False).value)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment