aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask/base')
-rwxr-xr-xwqflask/base/data_set.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index e4bdb5c3..803cbc4f 100755
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -27,8 +27,12 @@ import string
import collections
import json
+import cPickle as pickle
import itertools
+from redis import Redis
+Redis = Redis()
+
from flask import Flask, g
import reaper
@@ -70,6 +74,19 @@ def create_dataset(dataset_name, dataset_type = None):
dataset_class = globals()[dataset_ob]
return dataset_class(dataset_name)
+def create_datasets_list():
+ key = "all_datasets"
+ result = Redis.get(key)
+ if result:
+ print("Cache hit!!!")
+ result = pickle.loads(result)
+ else:
+ with Bench("Creating DataSets object"):
+ ds = DataSets()
+ Redis.set(key, pickle.dumps(result))
+ Redis.expire(key, 2*60)
+
+
def create_in_clause(items):
"""Create an in clause for mysql"""
in_clause = ', '.join("'{}'".format(x) for x in mescape(*items))