forked from OmniLayer/omniEngine
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cacher.py
36 lines (27 loc) · 786 Bytes
/
cacher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import config
import redis
import json
r = redis.StrictRedis(host=config.REDIS_HOST, port=config.REDIS_PORT, db=config.REDIS_DB)
try:
expTime=config.BTCBAL_CACHE
except:
expTime=600
def rGet(key):
return r.get(key)
def rSet(key,value):
return r.set(key,value)
def rExpire(key,sec):
return r.expire(key,sec)
def rDelete(key):
return r.delete(key)
def rKeys(key):
return r.keys(key)
def rSetNotUpdateBTC(baldata):
fresh=baldata['fresh']
if fresh!=None and len(fresh)>0:
for addr in fresh:
rSet("omniwallet:balances:address:"+str(addr),json.dumps( {"bal":baldata['bal'][addr],"error":None}))
rExpire("omniwallet:balances:address:"+str(addr),expTime)
def rExpireAllBalBTC():
for addr in rKeys("omniwallet:balances:address:*"):
rDelete(addr)