-
-
Notifications
You must be signed in to change notification settings - Fork 195
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 ability to ask external caches to invalidate. #7893
Conversation
032a22d
to
d4923b4
Compare
Hi @garethrees, yes, thanks, I've put all the detailed discussion on https://github.com/mysociety/sysadmin/issues/1824 |
567c622
to
7bda1a8
Compare
a50895d
to
38b15b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good to me. There are more I could do to this but for now I have committed some fixups to do things is slightly better Ruby approach but functionally this should be the same. Many thanks @dracos
Changes:
- remove multiple conditionals, in favour for a callback when enqueuing the job
- move post event logging code into InfoRequestEvent after create callback, and added specs
- refactored job, removing heavily nested code and improve success/failure logging.
Thanks - that callback is definitely nicer :) Only query I have is can Net::HTTP hold open a connection - I had it outside the URLs loop in the hope it would use the one connection for all of them, but probably makes no difference. |
Ah, as it is then no it doesn't. We can close the connection manually though if we don't use a do/end block. I'll push another fixup. |
Add a cached_urls method to the Comment, FoiAttachment, InfoRequest, PublicBody and User models, containing the entries that those models wish to invalidate either when an event is logged, via log_event, or when the censor rules change, or when a body or user is updated. The entries are fixed paths to be purged, or regexes beginning with ^ to be banned. Adds a NotifyCacheJob that for each of the object's cached_urls, for each locale, for each host in VARNISH_HOSTS, makes BAN or PURGE HTTP requests to the host, to invalidate the relevant entries.
c903b82
to
cb4846c
Compare
Add a cached_urls method to the Comment, FoiAttachment, InfoRequest, PublicBody and User models, containing the entries that those models wish to invalidate when an event is logged via log_event or when the censor rules change. Entries are either a fixed path to be purged or a regex beginning with '^' to be banned.
Adds a NotifyCacheJob that for each of the object's cached_urls, for each locale, for each host in VARNISH_HOSTS, makes BAN or PURGE HTTP requests to the host, to invalidate the relevant entries.