Skip to content

v0.0.9

New: Cached Method Wrappers (lythonic.compose.cached)

YAML-configured caching layer for sync and async download methods. Wraps methods that return dict or Pydantic BaseModel with SQLite-backed caching and probabilistic stale refresh.

  • CacheRegistry — loads YAML config, validates method signatures, creates per-method SQLite tables, builds sync/async wrappers, and installs them on a nested namespace object for attribute-based access.
  • CacheConfig / CacheRule — Pydantic models for cache configuration with min_ttl / max_ttl (in days) per method.
  • Probabilistic stale refresh — between min_ttl and max_ttl, refresh probability increases linearly. Avoids thundering herd on expiry.
  • Namespace — dot-separated paths in config create nested attribute access (e.g., cached.market.fetch_prices(ticker="AAPL")).
  • Dynamic DDL — cache tables are generated from method signatures with typed parameter columns and composite primary keys.

New: simple_type Flag on KnownType

KnownTypeArgs and KnownType now have a simple_type: bool field. Types whose string representation is a plain, URL-safe scalar are marked True. Auto-detected for primitives (int, float, bool, str), date, datetime, and Path. Used by the cache layer to validate that method parameters can serve as cache key columns.

New: Method.validate_simple_type_args()

Validates that all parameters of a method have type annotations registered as simple_type in KNOWN_TYPES. Raises ValueError with a clear message if any parameter fails. Used at config load time by CacheRegistry.

Fixes

  • Minor SQL formatting fix in DbModel select/delete query construction (string concatenation replaced with f-string interpolation).

Dependencies

  • Added pyyaml as a project dependency.

Documentation

  • Module docstring for lythonic.compose.cached with configuration, usage, TTL behavior, and validation sections.
  • Added "Simple Types" section to lythonic.types module docstring.
  • Added lythonic.compose.cached API reference page.
  • Added documentation guidelines section to CLAUDE.md.
  • Updated documenting.md with "What Goes Where" rules.