Skip to content

Add queryset cache #17

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

Merged
merged 2 commits into from
Feb 1, 2022
Merged

Add queryset cache #17

merged 2 commits into from
Feb 1, 2022

Conversation

bayangan1991
Copy link
Contributor

Add an optional cache to the resolution of extra fields and display conditions.

Copy link
Contributor

@Sticky-Bits Sticky-Bits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, so if we're not using the cache there's no relevant fields? That doesn't seem right?

@bayangan1991
Copy link
Contributor Author

If we aren't using the cache, the relevant fields is set to None so the next if block will always retrieve from the ORM

Copy link
Member

@jarekwg jarekwg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. How long are we caching for? Have we got confidence we won't get stuck on old data when extra fields change?

@Sticky-Bits Sticky-Bits self-requested a review February 1, 2022 05:13
Copy link
Contributor

@Sticky-Bits Sticky-Bits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, misread the code.

Yep, this looks good.

@Sticky-Bits
Copy link
Contributor

Looks good. How long are we caching for?

I would assume 30 minutes?

cache.set(cache_key, relevant_fields, 30)

@bayangan1991
Copy link
Contributor Author

Looks good. How long are we caching for? Have we got confidence we won't get stuck on old data when extra fields change?

Only 30 seconds, which will be refreshed when called within the context of the importer. No where else is set to use the cache at this current stage.

If we set the caching to be the default then the only issue I can see arising is on a particularly active server, the cache will keep getting refreshed before it can expire. This could be resolved by moving the cache.set() to only be called when we fetch from the db so the call will happen every 30 seconds regardless.

@bayangan1991 bayangan1991 merged commit f58c31e into master Feb 1, 2022
@bayangan1991 bayangan1991 deleted the add-queryset-cache branch February 1, 2022 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants