SourceCache

SourceCache()

A cache that uses the source file’s modification time as the cache key.

SourceCache is useful when you want to cache results based on when the source data file was last modified. If the source file changes, the cache will be invalidated automatically. Persistence depends on the source backend. Supports both remote (Snowflake, Postgres) and in-process (Pandas, DuckDB) backends.

Parameters

Name Type Description Default
source Backend The backend to use for execution. Defaults to xorq’s default backend. required

Example

import xorq.api as xo
from xorq.caching import SourceCache

con = xo.connect()
storage = SourceCache.from_kwargs(source=con)

expr = batting.filter(batting.yearID == 2015)
cached = expr.cache(storage)
result = xo.execute(cached)