Created On: January 14, 2022, Last Updated On: January 14, 2022
By Ozzie Ghani3 new
import redis
import json
DOMAIN = "xx.xxx.xxx.xx"
PORT = 1234
PASS = "password"
cache = redis.StrictRedis(host=DOMAIN, port=PORT, db=0, decode_responses=True, password=PASS)
cache.set("foo", "bar")
print(cache.get('foo'))
token = {"access_token": "RZHH7cal+VA==212FD3x19z9sWBHDJACbC00B75E",
"scope": ["PlaceTrades", "AccountAccess", "MoveMoney"],
"expires_in": 1800, "token_type": "Bearer", "expires_at": 1642143642.8040695,
"refresh_token": "asklfhaodklsfjhalskdjfhasiouflaksdjfhlaskjdhf"}
token = json.dumps(token) # convert to str
cache.set("token", token) # store in db
data = cache.get('token') # get from db
data = json.loads(data) # convert to json
print(data['access_token'])