Bug 18232 - Koha::Cache::flush - Simply flush all caches
Summary: Koha::Cache::flush - Simply flush all caches
Status: BLOCKED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Olli-Antti Kivilahti
QA Contact: Testopia
URL:
Keywords:
Depends on: 16140
Blocks: 19523
  Show dependency treegraph
 
Reported: 2017-03-08 15:48 UTC by Olli-Antti Kivilahti
Modified: 2020-01-11 23:16 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 18232 - Koha::Cache::flush - Simply flush all caches (1018 bytes, patch)
2017-03-08 15:50 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review
Bug 18232 - Koha::Cache::flush - Simply flush all caches - Squashable1, fix pesky syspref cache issue (1.23 KB, patch)
2017-10-24 13:50 UTC, Olli-Antti Kivilahti
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Olli-Antti Kivilahti 2017-03-08 15:48:18 UTC
This is handy when upgrading Koha or fiddling with config.
Comment 1 Olli-Antti Kivilahti 2017-03-08 15:50:19 UTC
Created attachment 60922 [details] [review]
Bug 18232 - Koha::Cache::flush - Simply flush all caches

So we can easily and without reading the code, figure out how to flush all caches.

    perl -e 'use Koha::Caches; Koha::Caches::flush();'

This is handy dandy when upgrading Koha or fiddling with configs.
Comment 2 Olli-Antti Kivilahti 2017-03-08 15:52:22 UTC
This might work or might not :)
flush is needed however.
I'll keep posting followups if this doesn't.
Comment 3 Katrin Fischer 2017-10-15 11:56:03 UTC
Assigning to Olli-Antti as he provided the patch.

Patch still applies, but I am not sure how to verify if it works correctly. Running the command from koha-shell gives no feedback, but no error either.
Leaving for another tester.

Something similar might already exist wrapped in commands like 'restart_all' on kohadevbox?
Comment 4 Olli-Antti Kivilahti 2017-10-24 13:50:23 UTC
Created attachment 68468 [details] [review]
Bug 18232 - Koha::Cache::flush - Simply flush all caches - Squashable1, fix pesky syspref cache issue

After flushing Koha::Caches this flush() also removed the references to the singleton caches, forcing
reinstating the cache connection.

C4::Context had a hard-coded package variable referencing to the sysprefs cache.
After flushing for the first time, the reference to the syspref cache was severed for Koha::Caches,
but not to the C4::Context syspref cache,
and flushing started to fail because the syspref cache was no longer referenced from Koha::Caches.

The original change was made to try to get around the memcached cache expiration issues.
And had this unintended side-effect.
Comment 5 Jon Knight 2017-10-25 07:51:17 UTC
Applied to master on my test kohadevbox cleanly and:

perl -e 'use Koha::Caches; Koha::Caches::flush();'

seems to run without any errors.

As with Katrin, I could do with a test plan to check its working.  I've tried poking around in memcached (using `memcached -vv` and `telnet localhost 11211` and then issuing stats commands), but I can't see much difference on a dev box to be honest. I'm guessing it needs a load of traffic sent to it to make the memcached caches fill up so that a flush is noticeable?
Comment 6 David Cook 2019-09-19 01:49:38 UTC
(In reply to Jon Knight from comment #5)
> Applied to master on my test kohadevbox cleanly and:
> 
> perl -e 'use Koha::Caches; Koha::Caches::flush();'
> 
> seems to run without any errors.
> 
> As with Katrin, I could do with a test plan to check its working.  I've
> tried poking around in memcached (using `memcached -vv` and `telnet
> localhost 11211` and then issuing stats commands), but I can't see much
> difference on a dev box to be honest. I'm guessing it needs a load of
> traffic sent to it to make the memcached caches fill up so that a flush is
> noticeable?

You could try the following for a more detailed view of what's in the cache if you have the right tools installed:

memdump --server localhost:11211
(might be memcdump on Debian)

memcat --server localhost:11211 KOHADEV:syspref:syspref_opacnavright
(might be memccat)