Bugzilla – Attachment 86631 Details for
Bug 22473
Use koha-conf.xml modification time as cache key
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22473: Example of watcher to invalidate config cache - V4
Bug-22473-Example-of-watcher-to-invalidate-config-.patch (text/plain), 1.40 KB, created by
Jonathan Druart
on 2019-03-14 19:06:45 UTC
(
hide
)
Description:
Bug 22473: Example of watcher to invalidate config cache - V4
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-03-14 19:06:45 UTC
Size:
1.40 KB
patch
obsolete
>From 1b5f86ea5cf5374730d006a24c59a1c03e973175 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 14 Mar 2019 15:52:26 -0300 >Subject: [PATCH] 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. >--- > watchfile.pl | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > create mode 100644 watchfile.pl > >diff --git a/watchfile.pl b/watchfile.pl >new file mode 100644 >index 0000000000..d9e6de127b >--- /dev/null >+++ b/watchfile.pl >@@ -0,0 +1,32 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use C4::Context; >+use Koha::Caches; >+ >+use Event; >+use Linux::Inotify2; >+ >+my $inotify = Linux::Inotify2->new; >+ >+Event->io (fd => $inotify->fileno, poll => 'r', cb => sub { $inotify->poll }); >+ >+our $filename = '/etc/koha/sites/kohadev/koha-conf.xml'; >+ >+sub cb { >+ my $e = shift; >+ >+ # Flushing the config >+ Koha::Caches->get_instance('config')->flush_all; >+ C4::Context->new; >+ >+ # We need to cancel the watcher and recreate it as the file has been modified (usually delete+creation) >+ $e->w->cancel; >+ >+ $inotify->watch ($filename, IN_MODIFY, \&cb); >+} >+ >+$inotify->watch ($filename, IN_MODIFY, \&cb); >+ >+Event::loop; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22473
:
86628
|
86629
|
86630
| 86631