def decorated_view(*args, **kwargs): slog = ( request.method, current_user.id, current_user.nickname, time.strftime("%Y-%m-%d %X", time.localtime()), request, request.form, ) logging.error(slog) print slog clog = cache.get("johnlog") if not clog: print "99999999999999" cache.set("johnlog", slog) slog = cache.get("johnlog") print slog if not current_user.is_authenticated(): return current_app.login_manager.unauthorized() if current_user.action(fn.__name__): return fn(*args, **kwargs) if request.is_xhr: return jsonify(result=False, error=u"权限不1足") abort(403)
def cache_test(): k = 'TEST' v = cache.get(k) if v: print 'exists = ',v else: cache.set(k,'1000') print 'no exists'
def cache_test(): k = 'TEST' v = cache.get(k) if v: print 'exists = ', v else: cache.set(k, '1000') print 'no exists'
def decorated_view(*args, **kwargs): slog = request.method,current_user.id,current_user.nickname,time.strftime("%Y-%m-%d %X", time.localtime()),request,request.form logging.error(slog) print slog clog = cache.get('johnlog') if not clog: print '99999999999999' cache.set('johnlog',slog) slog = cache.get('johnlog') print slog if not current_user.is_authenticated(): return current_app.login_manager.unauthorized() if current_user.action(fn.__name__): return fn(*args, **kwargs) if request.is_xhr:return jsonify(result=False,error=u'权限不1足') abort(403)
def do_cache(*args, **kws): if isinstance(cache_key,str):key=cache_key elif callable(cache_key):key = cache_key(*args,**kws) if thread_cache is True: if THREAD_CACHES.has_key(cache_key): return THREAD_CACHES[cache_key] data = cache.get(key) if data is not None:return data data = func(*args, **kws) cache.set(key,data,timeout_seconds) if thread_cache is True:THREAD_CACHES[key] = data return data
def do_cache(*args, **kws): if isinstance(cache_key, str): key = cache_key elif callable(cache_key): key = cache_key(*args, **kws) if thread_cache is True: if THREAD_CACHES.has_key(cache_key): return THREAD_CACHES[cache_key] data = cache.get(key) if data is not None: return data data = func(*args, **kws) cache.set(key, data, timeout_seconds) if thread_cache is True: THREAD_CACHES[key] = data return data
def decorator(*args, **kwargs): response = cache.get(request.path) if response is None: response = f(*args, **kwargs) cache.set(request.path, response, self.timeout) return response