def _(*a, **kw): key, args = gen_key(*a, **kw) start = args.pop('start', 0) limit = args.pop('limit') start = int(start) limit = int(limit) if not key or limit is None or start + limit > count: return f(*a, **kw) if isinstance(key, unicode): key = key.encode("utf8") r = mc.get(key) # anti miss-storm retry = max_retry while r is None and retry > 0: time.sleep(0.1) r = mc.get(key) retry -= 1 r = pickle.loads(r) if r else None if r is None: r = f(limit=count, **args) mc.set(key, pickle.dumps(r), expire) return r[start:start + limit]
def _(*a, **kw): key, args = gen_key(*a, **kw) start = args.pop('start', 0) limit = args.pop('limit') start = int(start) limit = int(limit) if not key or limit is None or start+limit > count: return f(*a, **kw) if isinstance(key, unicode): key = key.encode("utf8") r = mc.get(key) # anti miss-storm retry = max_retry while r is None and retry > 0: time.sleep(0.1) r = mc.get(key) retry -= 1 r = pickle.loads(r) if r else None if r is None: r = f(limit=count, **args) mc.set(key, pickle.dumps(r), expire) return r[start:start+limit]
def _(*a, **kw): key, args = gen_key(*a, **kw) if not key: return f(*a, **kw) if isinstance(key, unicode): key = key.encode("utf8") r = mc.get(key) # anti miss-storm retry = max_retry while r is None and retry > 0: time.sleep(0.1) r = mc.get(key) retry -= 1 r = pickle.loads(r) if r else None if r is None: r = f(*a, **kw) if r is not None: mc.set(key, pickle.dumps(r), expire) if isinstance(r, Empty): r = None return r