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

Add page view caching #186

Merged
merged 2 commits into from
May 13, 2024
Merged

Add page view caching #186

merged 2 commits into from
May 13, 2024

Conversation

erikh360
Copy link
Collaborator

/orderedcontent/ gets called multiple times per contact for figuring out what content to send.

get_unique_page_seen_ids does a call to the contentrepo that take 5-8 seconds to complete and we tried adding a index but there is nothing else we can do to improve the performance.

We're now caching the results for 5 hours and returning it to rapidpro where we will replace another page view call.

@@ -223,3 +223,5 @@
# something more human-readable.
# release="myapp@1.0.0",
)

Choose a reason for hiding this comment

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

Is this localhost url on line 227 valid in the cluster this is hosted on?

Choose a reason for hiding this comment

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

Probably doesn't matter as thats just the default if it can't find the env var.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah just the default for tests and things, I will set the env where I deploy it

@erikh360 erikh360 merged commit 3369c52 into develop May 13, 2024
1 check passed

ids = utils.get_unique_page_seen_ids(self.org, msisdn)
self.assertEqual(ids, [164, 165, 166])
ids = utils.get_unique_page_seen_ids(self.org, msisdn)
Copy link
Contributor

Choose a reason for hiding this comment

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

We are repeating the assert here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, calling twice to make sure the second time round the values comes from the cache and it's not doing another call to contentrepo and the results are still the same

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