-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(starfish): POC of long term cache #52364
Conversation
export function useGenericDiscoverQuery<T, P>(props: Props<T, P>) { | ||
const api = useApi(); | ||
const {orgSlug, route, options} = props; | ||
const url = `/organizations/${orgSlug}/${route}/`; | ||
const apiPayload = getPayload<T, P>(props); | ||
|
||
const res = useQuery<[T, string | undefined, ResponseMeta<T> | undefined], QueryError>( | ||
[route, apiPayload], | ||
[route, apiPayload, getDateComponentCacheKey(apiPayload.statsPeriod)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting this here does eliminate some control over when cache should be invalidated, maybe instead a prop containing additionalCacheKey
information would be better here. For example the response that contains the span op and the query itself shouldn't change regardless of stats period.
data[2].getResponseHeader = (headerName: string) => { | ||
if (headerName === 'Link') { | ||
return pageLinks; | ||
} | ||
return null; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit hacky, but it does allow us to retain the original api to get the response header. lmk if anyone has thoughts on this
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you remove the label "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
This PR will cache starfish responses in the localstorage,
if statsPeriod is in days, weeks or months, the response will be cached till the nearest hour
if statsPeriod is not in these units, the response will be cached till the nearest 5 minutes
I'm looking for feedback of if this is okay, and if this is on the right track. There is still more todo, but its mostly working as i've intented it to. i've documented TODOs below
TODO