diff options
author | Zachary Sloan | 2013-06-26 21:48:44 +0000 |
---|---|---|
committer | Zachary Sloan | 2013-06-26 21:48:44 +0000 |
commit | 9718fc35ac90640f9ff1324af077c99fe43c4900 (patch) | |
tree | 6495fd4265033337c33ef6f7956f8741f106fd0e /wqflask/base | |
parent | 6fbbfe5e8bcc3b57c4177687bbf67bf041da3cba (diff) | |
download | genenetwork2-9718fc35ac90640f9ff1324af077c99fe43c4900.tar.gz |
Moved code creating DataSets object to a function in dataset.py
Added caching to creating DataSets object
Diffstat (limited to 'wqflask/base')
-rwxr-xr-x | wqflask/base/data_set.py | 17 |
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)) |