def put(key, obj, remote): if remote: cloud.bucket.putf(pickle.dumps(obj), key) else: path = util.cachePath(key) dire = os.path.dirname(path) if not os.path.exists(dire): os.makedirs(dire) pickle.dump(obj, open(path, 'w'))
def clear(prefix, remote): if (remote): k = cloud.call(delete_prefix, prefix) return cloud.result(k) else: path = util.cachePath(prefix) if (os.path.isdir(path)): sh.rmtree(path) elif (os.path.isfile(path)): os.remove(path)
def get(key, remote): if remote: return pickle.loads(cloud.bucket.getf(key).read()) else: return pickle.load(open(util.cachePath(key), 'r'))