Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

DominikB2014
Copy link
Contributor

@DominikB2014 DominikB2014 commented Jul 6, 2023

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

  • Handle the case where statsPeriod is for example 72 hours
  • Make this only work on the dropdown, so we can test it there first.
  • Confirm adding this package is okay
  • Cleanup any jank
  • See if we will have to do any cleanup for responses that are invalidated

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jul 6, 2023
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)],
Copy link
Contributor Author

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.

Comment on lines +64 to +69
data[2].getResponseHeader = (headerName: string) => {
if (headerName === 'Link') {
return pageLinks;
}
return null;
};
Copy link
Contributor Author

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

@getsantry
Copy link
Contributor

getsantry bot commented Oct 19, 2023

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 Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Oct 19, 2023
@getsantry getsantry bot closed this Oct 27, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 11, 2023
@asottile-sentry asottile-sentry deleted the DominikB2014/long-term-caching branch December 27, 2023 16:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Frontend Automatically applied to PRs that change frontend components Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant