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 generic cache based on ttlcache #112

Merged
merged 1 commit into from
Jan 24, 2024
Merged

Add generic cache based on ttlcache #112

merged 1 commit into from
Jan 24, 2024

Conversation

rowanseymour
Copy link
Member

@rowanseymour rowanseymour commented Jan 24, 2024

and synced fetching logic used by mailroom asset loading

This should be usable for mailroom assets, courier channels and whatever we want to cache in temba-chat

Copy link

codecov bot commented Jan 24, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (424c323) 89.68% compared to head (e5af9ef) 90.25%.

Files Patch % Lines
cache/generic.go 93.87% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #112      +/-   ##
==========================================
+ Coverage   89.68%   90.25%   +0.56%     
==========================================
  Files          39       40       +1     
  Lines        1891     1940      +49     
==========================================
+ Hits         1696     1751      +55     
+ Misses        158      151       -7     
- Partials       37       38       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


// there's always a chance a different thread completed a fetch before we got here
// so check again now that we have a lock for the key
if item := c.cache.Get(key); item != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

this is something that mailroom asset loading doesn't do so I think under heavy load we're probably sometimes doing duplicate asset loads

@rowanseymour rowanseymour merged commit 2cea66e into main Jan 24, 2024
5 checks passed
@rowanseymour rowanseymour deleted the cache branch January 24, 2024 16:29
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants