示例#1
0
文件: rr.py 项目: weizhongjia/selinon
    def get(self, item_id, task_name=None, flow_name=None):
        """Get item from cache.

        :param item_id: item id under which the item is stored
        :param task_name: name of task that result should/shouldn't be cached, unused when caching Celery's AsyncResult
        :param flow_name: name of flow in which task was executed, unused when caching Celery's AsyncResult
        :return: item itself
        """
        if item_id not in self._cache:
            raise CacheMissError()

        return self._cache[item_id]
示例#2
0
    def get(self, item_id, task_name=None, flow_name=None):
        """Get item from cache.

        :param item_id: item id under which the item is stored
        :param task_name: name of task that result should/shouldn't be cached, unused when caching Celery's AsyncResult
        :param flow_name: name of flow in which task was executed, unused when caching Celery's AsyncResult
        :return: item itself
        """
        record = self._cache.get(item_id)

        # this if is safe as we store tuple - we handle even None results
        if not record:
            raise CacheMissError()

        # mark record usage
        self._remove_record(record)
        self._add_record(record)

        return record.item
示例#3
0
 def get(self, item_id, task_name=None, flow_name=None):
     raise CacheMissError("Result is not found in the cache")