Skip to content

feat: add opt-in session list caching with stale-while-revalidate#336

Merged
joshmedeski merged 1 commit intomainfrom
cache
Feb 18, 2026
Merged

feat: add opt-in session list caching with stale-while-revalidate#336
joshmedeski merged 1 commit intomainfrom
cache

Conversation

@joshmedeski
Copy link
Owner

@joshmedeski joshmedeski commented Feb 18, 2026

Note

this is an experimental opt-in caching feature that will speed up load times for sesh

Summary

  • Add file-based cache layer (cache/ package) using gob encoding at $XDG_CACHE_HOME/sesh/sessions.gob
  • Add CachingLister decorator with stale-while-revalidate strategy (5s soft TTL) that wraps the existing lister
  • Wire caching into deps.go behind a cache = true config flag, with automatic refresh after sesh connect

Why

Repeated sesh list / sesh pick calls can be slow when fetching from tmux, zoxide, and config sources. Caching returns instant results for subsequent calls while keeping data fresh via background revalidation.

Notes

  • Caching is opt-in and disabled by default -- no behavior change without cache = true in sesh.toml
  • Cache stores the full unfiltered session list; view-level filters like HideAttached are applied after cache read
  • Atomic writes via temp file + rename to prevent corruption
  • Comprehensive tests for both cache/ and lister/ packages
cache = true

@joshmedeski joshmedeski merged commit 1d763f5 into main Feb 18, 2026
4 checks passed
@joshmedeski joshmedeski deleted the cache branch February 18, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant