@@ -16,8 +16,9 @@ def RedisCheck(r):
16
16
DataFrame: Pandas dataframe to pass
17
17
Expire: Expires the data if true.
18
18
ExpireDuration: If expires is true, how much time to expire. Default 15 mins
19
+ Compression: "gzip", "bz2", 'zstd', 'tar', "zip", None
19
20
"""
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" ):
21
22
22
23
import os
23
24
import io
@@ -33,7 +34,7 @@ def pipeline_pandas_redis_store(StoreKey, DataFrame, Redis, Expire=True, ExpireD
33
34
raise Exception ("Redis connection failed." )
34
35
35
36
buffer = io .BytesIO ()
36
- DataFrame .to_pickle (buffer , compression = 'gzip' )
37
+ DataFrame .to_pickle (buffer , compression = Compression )
37
38
buffer .seek (0 ) # re-set the pointer to the beginning after reading
38
39
39
40
if Expire :
@@ -50,7 +51,7 @@ def pipeline_pandas_redis_store(StoreKey, DataFrame, Redis, Expire=True, ExpireD
50
51
StoreKey: is the key to look up for retrieval (set with RedisStore).
51
52
Redis: e.g. Redis = redis.Redis(host='redis-service', port=6379, db=0)
52
53
"""
53
- def pipeline_pandas_redis_get (StoreKey , Redis ):
54
+ def pipeline_pandas_redis_get (StoreKey , Redis , Compression = "gzip" ):
54
55
55
56
import os
56
57
import io
@@ -69,7 +70,7 @@ def pipeline_pandas_redis_get(StoreKey, Redis):
69
70
buffer = io .BytesIO (Redis .get (InsertKey ))
70
71
buffer .seek (0 )
71
72
import pandas as pd
72
- df = pd .read_pickle (buffer ,compression = 'gzip' )
73
+ df = pd .read_pickle (buffer ,compression = Compression )
73
74
74
75
duration = datetime .now () - start
75
76
0 commit comments