예제 #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")