@@ -16,8 +16,9 @@ def RedisCheck(r):
1616DataFrame: Pandas dataframe to pass
1717Expire: Expires the data if true.
1818ExpireDuration: If expires is true, how much time to expire. Default 15 mins
19+ Compression: "gzip", "bz2", 'zstd', 'tar', "zip", None
1920"""
20- def pipeline_pandas_redis_store (StoreKey , DataFrame , Redis , Expire = True , ExpireDuration = timedelta (minutes = 15 )):
21+ def pipeline_pandas_redis_store (StoreKey , DataFrame , Redis , Expire = True , ExpireDuration = timedelta (minutes = 15 ), Compression = "gzip" ):
2122
2223 import os
2324 import io
@@ -33,7 +34,7 @@ def pipeline_pandas_redis_store(StoreKey, DataFrame, Redis, Expire=True, ExpireD
3334 raise Exception ("Redis connection failed." )
3435
3536 buffer = io .BytesIO ()
36- DataFrame .to_pickle (buffer , compression = 'gzip' )
37+ DataFrame .to_pickle (buffer , compression = Compression )
3738 buffer .seek (0 ) # re-set the pointer to the beginning after reading
3839
3940 if Expire :
@@ -50,7 +51,7 @@ def pipeline_pandas_redis_store(StoreKey, DataFrame, Redis, Expire=True, ExpireD
5051StoreKey: is the key to look up for retrieval (set with RedisStore).
5152Redis: e.g. Redis = redis.Redis(host='redis-service', port=6379, db=0)
5253"""
53- def pipeline_pandas_redis_get (StoreKey , Redis ):
54+ def pipeline_pandas_redis_get (StoreKey , Redis , Compression = "gzip" ):
5455
5556 import os
5657 import io
@@ -69,7 +70,7 @@ def pipeline_pandas_redis_get(StoreKey, Redis):
6970 buffer = io .BytesIO (Redis .get (InsertKey ))
7071 buffer .seek (0 )
7172 import pandas as pd
72- df = pd .read_pickle (buffer ,compression = 'gzip' )
73+ df = pd .read_pickle (buffer ,compression = Compression )
7374
7475 duration = datetime .now () - start
7576
0 commit comments