Goal
--all pagination is slow and hits rate limits. Implement caching to reduce API calls across all paginated commands.
Approach
Shared cache module (src/lib/cache.ts)
Extract cache logic from resolve.ts into a reusable module. Store updatedAt instead of expiresAt.
Stale-while-revalidate for list resources
Applies to: users list, channels list, channels members
- Cache the full result (not just name→id like resolve currently does)
- If within TTL → return cache immediately
- If TTL expired → incremental revalidate: fetch from API, merge new entries, remove deleted ones, then return
- Have
resolve.ts read from this richer cache too (instead of its own separate cache)
- No data is ever thrown away on TTL expiry — always merge/update
Incremental append for history
Applies to: channels history --all
- Cache key:
{workspace}-history-{channelId}
- Store messages + newest
ts
- Next
--all run: pass newest cached ts as oldest, fetch only new messages, append, save
- Skip cache when
--before/--after are specified
- Trade-off: edits/deletes won't be reflected (append-only)
--no-cache flag
Add to commonArgs so all commands can bypass cache when needed.
Not caching (low value)
stars list, reactions list, files list, later list — change frequently, usually small result sets.
Execution order
- Extract shared cache module
- Add
--no-cache to commonArgs
- Cache
users list / channels list with stale-while-revalidate
- Cache
channels history --all with incremental append
Related
Goal
--allpagination is slow and hits rate limits. Implement caching to reduce API calls across all paginated commands.Approach
Shared cache module (
src/lib/cache.ts)Extract cache logic from
resolve.tsinto a reusable module. StoreupdatedAtinstead ofexpiresAt.Stale-while-revalidate for list resources
Applies to:
users list,channels list,channels membersresolve.tsread from this richer cache too (instead of its own separate cache)Incremental append for history
Applies to:
channels history --all{workspace}-history-{channelId}ts--allrun: pass newest cachedtsasoldest, fetch only new messages, append, save--before/--afterare specified--no-cacheflagAdd to
commonArgsso all commands can bypass cache when needed.Not caching (low value)
stars list,reactions list,files list,later list— change frequently, usually small result sets.Execution order
--no-cachetocommonArgsusers list/channels listwith stale-while-revalidatechannels history --allwith incremental appendRelated