def _reset_tracking(): if redis is None: return {} keys = redis.keys('gedgo_*') for key in keys: redis.delete(key) redis.set('gedgo_tracking_start', int(time.time()))
def geo_resolve_ip(ip_address): if redis is None: return try: response = requests.get('ipinfo.io/%s/json' % ip_address) j = response.json() j['requested'] = datetime.utcnow().isoformat() redis.set('gedgo_ip_%s', json.dumps(j)) except (requests.exceptions.RequestsException, ValueError): return
def _increment_key(key_name): try: pvc = int(redis.get(key_name)) except TypeError: pvc = 0 redis.set(key_name, pvc + 1)