Bug 22473 - Use koha-conf.xml modification time as cache key
Summary: Use koha-conf.xml modification time as cache key
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-07 12:23 UTC by Robin Sheat
Modified: 2019-07-26 06:22 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 22473: flush in psgi - V1 (1.57 KB, patch)
2019-03-14 18:30 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 22473: Two other places that do not work - V2 (1.03 KB, patch)
2019-03-14 18:30 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 22473: Handle config expiration in C4::Context->new - V3 (2.18 KB, patch)
2019-03-14 18:51 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 22473: Example of watcher to invalidate config cache - V4 (1.40 KB, patch)
2019-03-14 19:06 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Sheat 2019-03-07 12:23:41 UTC
From this IRC conversation:

<fridolin> rkrimme1: did you flush memcached ?
<magnuse> can't hurt :-) 
<magnuse> and yeah, i think you have to, for changes to koha-conf.xml to be picked up

if this is the case, when creating and accessing memcached for koha-conf values, the actual modification time of the koha-conf should be appended to the key values. This means that if the file is updated, the cache is automatically invalid.

It requires running stat on each request, but as the koha-conf file isn't actually being opened and parsed, this will be very fast.
Comment 1 Jonathan Druart 2019-03-14 18:30:35 UTC
Created attachment 86628 [details] [review]
Bug 22473: flush in psgi - V1

Here we are checking on each request

That could work, but do not feel robust

Moreover it will not affect scripts outside of plack
Comment 2 Jonathan Druart 2019-03-14 18:30:48 UTC
Created attachment 86629 [details] [review]
Bug 22473: Two other places that do not work - V2
Comment 3 Jonathan Druart 2019-03-14 18:51:20 UTC
Created attachment 86630 [details] [review]
Bug 22473: Handle config expiration in C4::Context->new - V3
Comment 4 Jonathan Druart 2019-03-14 19:06:45 UTC
Created attachment 86631 [details] [review]
Bug 22473: Example of watcher to invalidate config cache - V4

Test plan:
perl watchfile.pl
then update the config

Note that we do not handle everything, for instance the DB
credentials will not be taken into account. I guess we could call
  C4::Context->dbh({ new => 1 })
as well.
Comment 5 Jonathan Druart 2019-03-14 19:11:05 UTC
Here are 4 versions (to apply and test separately) that could work. Only the last one (V4) is, in my opinion, viable.
Comment 6 Martin Renvoize 2019-03-26 08:00:10 UTC
Not forgotten about this, it's just in a long queue to take a look.. Thanks for all the alternations to look at Jonathan.. I hope to come back to this soon and take a proper look :)