Conversation
wagtailcache/models.py
Outdated
| def active(self): | ||
| return self.filter(expiry__gt=now()) | ||
|
|
||
| def active_for_url_regexes(self, urls=None): |
There was a problem hiding this comment.
I would prefer to enforce urls: List[str] in the signature, and make it required, rather than the fallback and casting logic below.
wagtailcache/cache.py
Outdated
| # Save the keyring. | ||
| _wagcache.set("keyring", keyring) | ||
| if urls: | ||
| active_keys = KeyringItem.objects.active_for_url_regexes( |
There was a problem hiding this comment.
If this returns a querystring... could you not instead call KeyringItem.objects.active_for_url_regexes(urls).delete() ?
|
Very nice implementation. Thank you! I left a few comments. Also, another bug fix has been merged in recently (adds a try/catch in |
wagtailcache/models.py
Outdated
| self.clear_expired() | ||
| return item | ||
|
|
||
| def bulk_delete_cache_keys(self, keys: List[str]) -> None: |
There was a problem hiding this comment.
Would prefer if keys is a QuerySet. Because during the delete, we are normally querying keys to delete, flattening them as values list, then passing it in here and re-querying. Double hits to the database. Would prefer to only make one database hit.
655d734 to
dfb02fe
Compare
|
I've just reverted this to draft because we're finding that calling |
|
Interesting - are you using ASGI by chance? Or is this caused by concurrent calls to |
|
It's not ASGI, but there are lots of servers and workers. We were getting many concurrent requests creating calls to I'll tidy it up and re-submit the PR. |
bbf117b to
25b888e
Compare
- 'testserver' is not a valid netloc so fails Django's validation. - tests for very long URLs
25b888e to
2386b30
Compare
This moves the keyring into the database to avoid duplication and also keep it up to date.
It would replace #63