python - How to store Gzipped content in Aerospike (cache)? -


i'm using aerospike python client here. don't find problem while storing plain string in cache because when retrieve key, same string saved when conn.get(key)

import aerospike  conn_aerospike_config = {'hosts': [('127.0.0.1', 3000)]} conn = aerospike.client(conn_aerospike_config).connect() key = ('namspace_name', 'set_name', 'key_name') value = "some big string" conn.put(key, {'value': value}) 

if want save gzipped content in place of value, don't find error i'm unable exact content.

from gzip import gzipfile io import bytesio def compress_string(s):     zbuf = bytesio()     gzipfile(mode='wb', compresslevel=6, fileobj=zbuf, mtime=0) zfile:         zfile.write(s)     return zbuf.getvalue()  put_value = compress_string(value) conn.put(key, {'value': put_value}) _, _, get_value = conn.get(key) 

i checked printing values of put_value, get_value. don't match, , need gzipped content, because content exceeds 1mb , need gzipped content only. please guide me i'm doing wrong.


i know can break content smaller chunks storing , concatenate after getting them, again need gzip content after getting data. thought why not store directly gzipped content, doesn't seems working me. leads appreceated, thank you.

if put_value string, truncated on first \0 character encountered. try converting put_value bytearray before sending down:

conn.put(key, {'value': bytearray(put_value,"utf-8")}) 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -