Skip to content

Explore incremental caching for channels history --all #24

@ygpark80

Description

@ygpark80

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

  1. Extract shared cache module
  2. Add --no-cache to commonArgs
  3. Cache users list / channels list with stale-while-revalidate
  4. Cache channels history --all with incremental append

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions