示例#1
0
class Content(object):
    max_list_age_days = 3

    def __init__(self, cache_maxsize=128):
        self.reason_cache = FunctionCacheManager(self.get_reason_list,
                                                 cache_maxsize)

    def clear(self):
        self.reason_cache.clear()

    def get_reason_list(self, url):
        try:
            http_client = HTTPClient()
            response = http_client.fetch(url)
            data = tornado.escape.json_decode(response.body)

            min_created_date_allowed = (
                datetime.now() -
                timedelta(days=self.max_list_age_days)).isoformat()
            if data["created"] < min_created_date_allowed:
                return None
            else:
                return data["results"]
        except HTTPError as e:
            print("Error=%s,url=%s" % (str(e), url))
示例#2
0
文件: content.py 项目: rdefeo/suggest
class Content(object):
    max_list_age_days = 3

    def __init__(self, cache_maxsize=128):
        self.reason_cache = FunctionCacheManager(self.get_reason_list, cache_maxsize)

    def clear(self):
        self.reason_cache.clear()

    def get_reason_list(self, url):
        try:
            http_client = HTTPClient()
            response = http_client.fetch(url)
            data = tornado.escape.json_decode(response.body)

            min_created_date_allowed = (datetime.now() - timedelta(days=self.max_list_age_days)).isoformat()
            if data["created"] < min_created_date_allowed:
                return None
            else:
                return data["results"]
        except HTTPError as e:
            print("Error=%s,url=%s" % (str(e), url))
示例#3
0
 def __init__(self, context_data: ContextData, attribute_product_data: AttributeProductData):
     self.entity_product_count_cache = FunctionCacheManager(self.__get_entity_product_count, 1000)
     self.context_data = context_data
     self.attribute_product_data = attribute_product_data
     self._global_weightings = {
         "brand": 100.0,
         "color": 90.0,
         "style": 80.0,
         "theme": 70.0,
         "season": 70.0,
         "detail": 60.0,
         "material": 50.0,
         "popular": 30.0,
         "added": 20.0
     }
示例#4
0
 def __init__(self, cache_maxsize=128):
     self.reason_cache = FunctionCacheManager(self.get_reason_list,
                                              cache_maxsize)
示例#5
0
 def __init__(self, directory, file_ext=None, cache_size=None):
     self.directory = directory
     self.file_ext = file_ext
     if cache_size is not None:
         from pylru import FunctionCacheManager
         self.get = FunctionCacheManager(self.get, size=cache_size)
示例#6
0
文件: content.py 项目: rdefeo/suggest
 def __init__(self, cache_maxsize=128):
     self.reason_cache = FunctionCacheManager(self.get_reason_list, cache_maxsize)
示例#7
0
 def __init__(self, directory, file_ext=None, cache_size=None):
     """Initialize a NeuronLoader object."""
     self.directory = directory
     self.file_ext = file_ext
     if cache_size is not None:
         self.get = FunctionCacheManager(self.get, size=cache_size)