fastrag.ingestion.cache.ids#

Cache identity helpers, shared by every step that caches.

A cache id has the "{step}:{hash}" shape shown in docs/specification/API.md’s Example 1 ("webcrawler:1a2b3c4") and Example 2 ("charactertextsplitter:e21qcasg"): the step’s (lowercased) name, then a short digest of what makes this particular cache entry unique.

Both helpers build on content_hash rather than adding a second hashing scheme — the digest is just content_hash of the two identifying strings joined by a separator that cannot occur in either half’s raw form (a colon would: URIs and document ids may contain one).

Functions

document_cache_id(step_name, document_id, ...)

Return the cache id for one document under one step configuration.

source_cache_id(step_name, target, config_hash)

Return the cache id for one fetch target under one step configuration.

fastrag.ingestion.cache.ids.source_cache_id(step_name, target, config_hash)[source]#

Return the cache id for one fetch target under one step configuration.

Parameters:
  • step_name (str) – The fetching step’s class name, e.g. "WebCrawler".

  • target (str) – What was fetched, e.g. a start URL — cached independently per target to increase the cache hit rate.

  • config_hash (str) – The step’s config_hash.

Return type:

str

fastrag.ingestion.cache.ids.document_cache_id(step_name, document_id, config_hash)[source]#

Return the cache id for one document under one step configuration.

Parameters:
  • step_name (str) – The transforming step’s class name, e.g. "CharacterTextSplitter".

  • document_id (str) – The upstream Document’s id — cached independently per document to increase the cache hit rate.

  • config_hash (str) – The step’s config_hash.

Return type:

str