Main Koha release repository https://koha-community.org
Find a file
Jared Camins-Esakov b07f4debb7 Bug 9434: Introduce new tied cache system
At the moment we cache numerous pieces of information in module-level
variables which then do not get updated in other threads/processes when
they are changed by the user. This is a serious usability issue.

Examples of this include the way we treat sysprefs (there is now a
method to disable the syspref cache, but by default it is enabled),
notices, frameworks, field mappings, and koha-conf.xml, at least.

This patch sets the stage for eliminating this problem by making it
possible to convert module-level cache variables into variables that
are actually backed by whatever caching system may be configured. This
is done through a special Koha::Cache::Object class which can be tied
to the variables that are being used for caching and provided with a
constructor method/closure to allow the cache to be reloaded when it
expires. For example:

    my $cache    = Koha::Cache->new();
    my $data     = 'whatever';
    my $variable = Koha::Cache->create_scalar(
        {
            'key'         => 'whatever',
            'timeout'     => 2,
            'constructor' => sub { return $data; },
        }
    );
    print "$$variable\n"; # Prints "whatever"

The one change this necessitates for accessing the data is that the
variable must be dereferenced an additional time before use (i.e.
$$variable instead of $variable). There is no difference when the
variable tied is a hash (created with Koha::Cache->create_hash). This
is a small price to pay for Koha working in a multi-threaded, persistent
environment. This change will also make caching easier in general.

CHI was incompatible with the variable tying, so this patch also removes
the dependency on CHI, using instead Cache::Memcached::Fast,
Cache::FastMmap, and Cache::Memory, when they are available.

To test:
1) Apply patch.
2) Run unit test t/Cache.t (after setting the MEMCACHED_SERVERS and
   CACHING_SYSTEM environment variables). As no changes were made to
   the tests already in that file, this passing demonstrates there
   are no regressions.
3) With memcached caching enabled (you must set the MEMCACHED_SERVERS
   and CACHING_SYSTEM environment variables) and DEBUG turned on (i.e.
   the DEBUG environment variable set to 1), try running a report via
   the web service ([intranet]/cgi-bin/koha/svc/report?id=1 and check
   your web server logs to confirm that there are messages like
   "get_from_cache for intranet:report:id:1" in them.
4) If the reports worked, sign off.

NOTE: Technically you could test this without needing memcached by
installing libcache-fastmmap-perl and setting CACHING_SYSTEM to
'fastmmap' instead of 'memcached'. You could also install libcache-perl
and set CACHING_SYSTEM to 'memory' but there would be little point as
the cached variables would go out of scope in between runs.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
2013-03-20 15:15:44 -04:00
acqui Bug 7018 : need all acq permissions to search 2013-03-20 08:05:04 -04:00
admin Bug 9760: Simplify local use preferences 2013-03-13 08:56:30 -04:00
authorities BUG 9145: Authorities: standard language for UNIMARC 2013-02-20 08:42:10 -05:00
basket Bug 9073 - Download option from the cart should match the menu button in lists 2012-11-25 18:08:46 -05:00
C4 Bug 9434: Introduce new tied cache system 2013-03-20 15:15:44 -04:00
catalogue Bug 9875: Hide empty items tab 2013-03-20 14:37:52 -04:00
cataloguing Bug 9239: Allow the use of QueryParser for all queries 2013-03-16 21:32:32 -04:00
circ Bug 9423: Add notforloan value to issue confirmation or blocking message 2013-03-19 22:22:23 -04:00
debian Bug 9802 - add test case to ensure man pages have correct XML 2013-03-20 15:11:10 -04:00
docs Add Fred Pierre to history 2013-01-17 20:55:20 -05:00
errors Housekeeping in errors scripts 2010-05-12 07:29:03 -04:00
etc Bug 7804 - Add Koha Plugin System 2013-03-20 14:49:47 -04:00
install_misc Bug 9267 - Ubuntu 12.04 install docs broken 2013-03-07 09:46:55 -05:00
installer Bug 7804: Increment version number 2013-03-20 14:51:15 -04:00
Koha Bug 9434: Introduce new tied cache system 2013-03-20 15:15:44 -04:00
koha-tmpl Bug 7804 - Add Koha Plugin System - QA Followup 2 2013-03-20 14:50:19 -04:00
labels Bug 9239: Allow the use of QueryParser for all queries 2013-03-16 21:32:32 -04:00
members Bug 9367: Code optimization: CheckReserves is too often called 2013-03-16 11:49:43 -04:00
misc Update release notes for 3.12-alpha2 release 2013-03-20 10:12:27 -04:00
offline_circ Bug 9263: Trim barcodes in offline circulation 2013-01-22 19:12:22 -05:00
opac Bug 9875: Hide empty items tab 2013-03-20 14:37:52 -04:00
OpenILS Bug 9239 QA follow-up: remove stray debug code 2013-03-16 21:32:34 -04:00
patroncards Bug 9695 - Use alphabet system preference on page used to browse patrons for patron card batches 2013-03-13 08:43:25 -04:00
plugins Bug 7804 - Add Koha Plugin System - QA Followup 2 2013-03-20 14:50:19 -04:00
reports Bug 9417 - Allow number of results per page to be selectable for guided reports 2013-02-08 09:34:54 -05:00
reserve Bug 9108: Followup: send the dateformat value from C4::Auth 2013-01-17 21:59:30 -05:00
reviews Bug 1623 - Provide view of approved comments 2011-12-27 18:26:50 +01:00
rotating_collections Bug 6553 : Follow up adding license statements 2011-08-13 19:54:38 +12:00
selenium Adding selenium tests for filterMembers 2009-09-30 11:30:37 +02:00
serials Bug 9827: remove 'insecure' system preference 2013-03-19 21:46:34 -04:00
services Bug 7178: Acquisition item creation improvement 2012-03-26 11:07:23 +02:00
skel Bug 7804 - Add Koha Plugin System 2013-03-20 14:49:47 -04:00
sms Bug 2505 - Add commented use warnings where missing in the sms/ directory 2010-04-21 20:25:08 +12:00
suggestion Bug 9226: Wrong branch filter after suggestion creation 2013-02-15 08:34:11 -05:00
svc Bug 9827: remove 'insecure' system preference 2013-03-19 21:46:34 -04:00
t Bug 9434: Introduce new tied cache system 2013-03-20 15:15:44 -04:00
tags bug 9401: remove direct reads of CGISESSID cookie by JavaScript 2013-02-01 11:05:35 -05:00
test Bug 5449: JSON malformed in Koha - Blocker with jQuery 1.4.x 2011-03-12 08:53:41 +13:00
tmp/modified_authorities
tools Bug 9415: XML catalog export is missing root node 2013-03-19 22:07:02 -04:00
virtualshelves Bug 7788: [SIGNED-OFF] Followup: GetShelf call in addbybiblio script corrected 2012-05-22 12:06:26 +02:00
xt Bug 9802 - add test case to ensure man pages have correct XML 2013-03-20 15:11:10 -04:00
.htaccess Fix file permissions: if it is not a script, it should not be executable. 2010-04-16 00:40:34 -04:00
.mailmap 7439 Mailmap for master 2012-01-27 12:27:58 +01:00
about.pl Bug 7440 - Remove NoZebra vestiges 2013-03-19 21:17:04 -04:00
changelanguage.pl Bug 6755 Problems with switching languages 2011-09-23 09:47:09 +12:00
edithelp.pl Bug 8622: Fix theme fallback 2012-09-05 11:39:14 +02:00
fix-perl-path.PL installer: improvements to fix-path-perl.PL on Win32 2007-12-20 19:20:12 -06:00
help.pl Bug 8949: Trying to view help on a page without any help results in a nasty error 2012-11-05 08:39:23 -05:00
INSTALL Bug 7759, update of install files to use background indexing (and some whitespace tidy) 2012-04-20 16:11:52 +02:00
install-CPAN.pl Bug 5370: Fix all the references to koha.org 2010-11-08 09:41:49 +13:00
INSTALL.debian Bug 8092 follow-up: Add optional dependency on CHI 2012-06-09 13:08:18 +02:00
INSTALL.fedora7 Bug 7440 - Remove NoZebra vestiges 2013-03-19 21:17:04 -04:00
INSTALL.opensuse Bug 7759, update of install files to use background indexing (and some whitespace tidy) 2012-04-20 16:11:52 +02:00
INSTALL.ubuntu Bug 8092 follow-up: Add optional dependency on CHI 2012-06-09 13:08:18 +02:00
INSTALL.ubuntu.12.04 Bug 9267 - Ubuntu 12.04 install docs broken 2013-03-07 09:46:55 -05:00
INSTALL.ubuntu.lucid Bug 8092 follow-up: Add optional dependency on CHI 2012-06-09 13:08:18 +02:00
koha_perl_deps.pl Bug 8485 - Make koha_perl_deps.pl batch friendly Added a -b flag for brief which outputs only the perl library name (Foo::BaR), and added a -r flag for required which filters the list to required=Yes perl libraries. 2012-08-31 17:35:49 +02:00
kohaversion.pl Bug 7804: Increment version number 2013-03-20 14:51:15 -04:00
LICENSE Bug 9440 - update Koha's LICENSE file from GPL2 to GPL3 2013-02-12 08:52:10 -05:00
mainpage.pl Revert "Bug 7167: New version for updatedatabase" 2012-12-27 14:02:56 -05:00
Makefile.PL Bug 7804 - Add Koha Plugin System 2013-03-20 14:49:47 -04:00
MANIFEST.SKIP Bug 9546 : Updating make manifest tardist 2013-02-06 23:54:46 -05:00
README Bug 9440 - update Koha's LICENSE file from GPL2 to GPL3 2013-02-12 08:52:10 -05:00
README.robots Bug 6411 add another example to README.robots 2011-07-05 14:48:05 +12:00
rewrite-config.PL Bug 7804 - Add Koha Plugin System 2013-03-20 14:49:47 -04:00

Koha is a free software integrated library system.

Koha is distributed under the GNU GPL version 3 or later.
Please read the file LICENSE for more details.

To install or upgrade Koha, please see the INSTALL file appropriate
to your platform.

Report bugs at http://bugs.koha-community.org/

Visit the Koha Project website at http://www.koha-community.org/