Пример #1
0
# -*- coding: utf-8 -*-
"""

"""
__author__ = 'pliu'

from functools import wraps
import pickle

from core import response, request
from core import redis_util
import logging
from common.log import log_enter, log_error, log_return


redis_cache = redis_util.create_redis_session()
Cache_Service = redis_util.create_redis_session
# def cache(fn, key_prefix, timeout=3600):
#     @wraps(fn)
#     def decorate(*q, **kw):
#         key = _generate_key(fn, *q, **kw)
#         data = _get(key)
#         cache_tag = 'Hit Cache'
#         if not data:
#             cache_tag = 'Miss Cache'
#             data = fn(*q, **kw)
#             _put(key, data, timeout)
#         response.set_header('Cache-Control: max-age', timeout)
#         response.set_header('JAMDEO_CACHE', cache_tag)
#         return data
#     return decorate
Пример #2
0
def Cache_Service():
    return create_redis_session()
Пример #3
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import pickle
from core.settings import settings
from core.redis_util import create_redis_session, VodRedis
from core import request, response
from redis.exceptions import ConnectionError
from functools import wraps
import pickle
import time
import logging

logger = logging.getLogger('cache_service')

redis_session = create_redis_session()


def has_key(session, cur_request):
    return session.hexists(cur_request.fullpath,
                           cur_request.query_string)


def default_get_from_key(session, cur_request):
    return pickle.loads(session.hget(cur_request.fullpath, cur_request.query_string))


def default_set_data(session, cur_request, data):
    session.hset(cur_request.fullpath, cur_request.query_string, data)

Пример #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

"""
__author__ = 'pliu'

from functools import wraps
import pickle

from core import response, request
from core import redis_util
import logging
from common.log import log_enter, log_error, log_return

redis_cache = redis_util.create_redis_session()
Cache_Service = redis_util.create_redis_session
# def cache(fn, key_prefix, timeout=3600):
#     @wraps(fn)
#     def decorate(*q, **kw):
#         key = _generate_key(fn, *q, **kw)
#         data = _get(key)
#         cache_tag = 'Hit Cache'
#         if not data:
#             cache_tag = 'Miss Cache'
#             data = fn(*q, **kw)
#             _put(key, data, timeout)
#         response.set_header('Cache-Control: max-age', timeout)
#         response.set_header('JAMDEO_CACHE', cache_tag)
#         return data
#     return decorate
Пример #5
0
def Cache_Service():
    return create_redis_session()
Пример #6
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

import pickle
from core.settings import settings
from core.redis_util import create_redis_session, VodRedis
from core import request, response
from redis.exceptions import ConnectionError
from functools import wraps
import pickle
import time
import logging

logger = logging.getLogger('cache_service')

redis_session = create_redis_session()


def has_key(session, cur_request):
    return session.hexists(cur_request.fullpath, cur_request.query_string)


def default_get_from_key(session, cur_request):
    return pickle.loads(
        session.hget(cur_request.fullpath, cur_request.query_string))


def default_set_data(session, cur_request, data):
    session.hset(cur_request.fullpath, cur_request.query_string, data)