How to store Gzipped content in Aerospike (cache)?

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

import aerospike

CONN_AEROSPIKE_CONFIG = {'hosts': [('', 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 I want to save gzipped content in the place of value, I don’t find any error but I’m unable to get back the exact content.

from gzip import GzipFile
from io import BytesIO
def compress_string(s):
    zbuf = BytesIO()
    with GzipFile(mode='wb', compresslevel=6, fileobj=zbuf, mtime=0) as zfile:
    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. They don’t match, and I need gzipped content, because my content exceeds 1MB and I need gzipped content only. Please guide me where I’m doing wrong.

I know that we can break the content into smaller chunks for storing and concatenate after getting them, but again I need to Gzip the content after getting the data. So I thought why not store directly Gzipped content, but that doesn’t seems to be working for me. Any leads are appreciated, Thank you.

© 2015 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.