I want to store data into redis from pandas through a cron job every 15 minute and below is my code:-
I am taking data into pandas every 15 minutes with below code and sending it to the redis dictionary mydict2 through a cron job.
import sys
import pickle
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
test_dict1 = results_df.set_index('user')['ua'].T.to_dict()
p_mydict = pickle.dumps(test_dict1)
r.set('mydict2', p_mydict)
I am getting the same output again and again in the key mydict2. Basically i want to store user ids for the whole month and at the end of the month i want the unique count of that.
Also i am using set method, what could be the best method assuming i am having a very large amount of data.
Can someone help me out here.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…