Skip to main content

cache

stats, schema, sniff, analyze, headers and count keep their result for a local file in ~/.undatum/cache. A later run on the unchanged file with the same options prints the same output without reading the data again. On 1M CSV rows, stats --json takes 1.3 s the first time and 0.2 s from the cache; sniff takes 0.6 s and 0.15 s.

undatum stats data.csv # reads the file and keeps the result
undatum stats data.csv # prints the kept result
undatum stats data.csv --no-cache # reads the file again, keeps nothing
undatum -v stats data.csv # says on stderr when it uses a kept result

A result belongs to:

  • the file's real path, its size and its modification time (to the nanosecond);
  • the undatum version;
  • the options that change the result (--engine, --where, --checkdates, the reader options, ...), and the path as you typed it.

Output options (--json, --format-out, --output, --format) and speed options (--threads, DuckDB limits) share one result. A changed file gets new results. A file modified in the last two seconds, or while it is read, is not cached: some filesystems keep the modification time for writes that close together.

Not cached:

  • standard input, URIs, and directories;
  • analyze --autodoc, whose AI descriptions are written anew every time (schema --autodoc reuses the inferred schema and asks the AI again);
  • calls from the Python SDK and the MCP server.

Turn the cache off with --no-cache for one run, UNDATUM_CACHE=0 for a shell, or in a config file:

defaults:
cache: false

UNDATUM_CACHE_DIR moves the cache directory.

# The cached files, their results and sizes; stale files are gone or changed
undatum cache list
undatum cache list --json

# Remove the results of gone or changed files, or all results
undatum cache clear --stale
undatum cache clear

A result is kept as long as its file is unchanged. A file edited by a tool that restores both its size and its modification time is not noticed; use --no-cache or cache clear for such files.

Reference​

undatum cache list​

undatum cache list [OPTIONS]
OptionDescriptionDefault
--jsonPrint the result as one JSON document (same as --format-out json).

undatum cache clear​

undatum cache clear [OPTIONS]
OptionDescriptionDefault
--staleRemove only the results of files that are gone or changed.

See also shared options.