redisactions.py 1.22 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
# third party imports
import redis
from __init__ import redisdb

# I'm thinking we store a couple things
# first: a key-value where the value is the dictlist
# second: a k-v for a list of errored events

# use rpush(key, value) to append a dblist (rpushx() to check if it exists)
# use del(key) to remove a k-v

12
# so everytime we run parscript or gcscript we want to run a dbfill()
13 14 15
# function. and every time we find an error we want to run a dberrorfill()
# function.

16
# this will update the live dictlist and the cachedate
17 18 19 20 21 22 23
# returns true if the dictlist is not empty, false otherwise
def gcdbfill(dictlist):
    try:
        redisdb.set("gcdict", dictlist)
    except e:
        return False

24
    return redisdb.get("gcdict") is not None
25 26

# saves new dictlist in place of previous 25Live dictlist
27
# returns true if the dictlist is not empty, false otherwise
28 29 30 31 32 33
def livedbfill(dictlist):
    try:
        redisdb.set("livedict", dictlist)
    except e:
        return False
        
34 35 36 37 38 39 40 41
    return redisdb.get("livedict") is not None

# saves the last time the cache was updated
# return true if the cachedate is not empty, false otherwise
def setlastcachedate(cache, date):
    try:
        redisdb.set(cache, date)
    except e:
42
        return False