jperasmus / jperasmus/stale-while-revalidate-cache

Include `status`, `staleAt`, `expireAt` etc. to the `retrieve` result

Open
#46 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
80
Forks
6
Avg merge
9m
Merged PRs (30d)
1

Description

Hi again-

I have a use case where I need to "peek" at the value in the cache and kick off a promise if stale/expired, so that I can tell the serverless environment I'm using to not die until the promise is resolved. I can do this with await swr.retrieve(myKey), but that only gives me cachedValue, cachedAge, cachedAt and now - not the status helpers etc.

Could it be refactored so I get the extra props too?

Happy to open a PR if you agree

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the swr.retrieve entry point and review how its current result exposes cachedValue, cachedAge, cachedAt, and now. Confirm how the status helpers and staleAt/expireAt values are represented, then verify that the retrieve result exposes the requested properties.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.