jina.drivers.cache

class jina.drivers.cache.BaseCacheDriver(with_serialization=False, *args, **kwargs)[source]

Bases: jina.drivers.index.BaseIndexDriver

The driver related to BaseCache

Parameters
  • with_serialization (bool) – feed serialized doc to the CacheIndexer

  • args

  • kwargs

on_miss(doc, data)[source]

Function to call when doc is missing, the default behavior is add to cache when miss :type doc: Document :param doc: the document in the request but missed in the cache

Return type

None

on_hit(req_doc, hit_result)[source]

Function to call when doc is hit :type req_doc: Document :param req_doc: the document in the request and hitted in the cache :type hit_result: Any :param hit_result: the hit result returned by the cache :rtype: None :return:

class jina.drivers.cache.TaggingCacheDriver(tags, *args, **kwargs)[source]

Bases: jina.drivers.cache.BaseCacheDriver

Label the hit-cache docs with certain tags

Parameters

tags (Dict) – the tags to be updated on hit docs

on_hit(req_doc, hit_result)[source]

Function to call when doc is hit :type req_doc: Document :param req_doc: the document in the request and hitted in the cache :type hit_result: Any :param hit_result: the hit result returned by the cache :rtype: None :return: