[Patches] [PATCH] [SIGNED-OFF] Bug 7248 : Caching support and Syspref

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Wed Dec 21 03:10:48 NZDT 2011


From: Chris Hall <chrish at catalyst.net.nz>
Date: Mon, 21 Nov 2011 16:00:37 +1300
Subject: [PATCH] [SIGNED-OFF] Bug 7248 : Caching support and Syspref

In the new Koha namespace as they don't call any routines from C4

Squashed commit of the following:

commit c887559d575464f3ac4fccb4db0cce2872cf633c
Author: Chris Hall <chrish at catalyst.net.nz>
Date:   Mon Nov 21 13:33:53 2011 +1300

    added missing sysprefs.sql entry for usecache setting

    http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7248

commit 177676f5f0591b9231eed73fdb21066589c2274d
Author: Chris Hall <chrish at catalyst.net.nz>
Date:   Mon Nov 21 11:38:23 2011 +1300

    Caching support and syspref

    http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=7248

Signed-off-by: Chris Cormack <chrisc at catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83 at web.de>
Adds new system preference usecache under administration.
Checked the system preference works.
Also ran the test successfully.
---
 {C4 => Koha}/Cache.pm                              |   13 ++++++-------
 {C4 => Koha}/Cache/Memcached.pm                    |    7 +++----
 installer/data/mysql/sysprefs.sql                  |    2 +-
 installer/data/mysql/updatedatabase.pl             |    6 ++++++
 .../prog/en/modules/admin/preferences/admin.pref   |   10 +++++++++-
 5 files changed, 25 insertions(+), 13 deletions(-)
 rename {C4 => Koha}/Cache.pm (84%)
 rename {C4 => Koha}/Cache/Memcached.pm (95%)

diff --git a/C4/Cache.pm b/Koha/Cache.pm
similarity index 84%
rename from C4/Cache.pm
rename to Koha/Cache.pm
index 151a3fa..7d39c3d 100644
--- a/C4/Cache.pm
+++ b/Koha/Cache.pm
@@ -1,4 +1,4 @@
-package C4::Cache;
+package Koha::Cache;
 
 # Copyright 2009 Chris Cormack and The Koha Dev Team
 #
@@ -19,7 +19,7 @@ package C4::Cache;
 
 =head1 NAME
 
-C4::Cache - Handling caching of html and Objects for Koha
+Koha::Cache - Handling caching of html and Objects for Koha
 
 =head1 SYNOPSIS
 
@@ -49,17 +49,16 @@ use Carp;
 
 use base qw(Class::Accessor);
 
-use C4::Cache::Memcached;
+use Koha::Cache::Memcached;
 
 __PACKAGE__->mk_ro_accessors( qw( cache ) );
 
 sub new {
     my $class = shift;                                                          
-    my %param = @_;                                                             
-    
-    my $cache_type = $param{cache_type} || 'memcached';
+    my $param = shift;                                                             
+    my $cache_type = $param->{cache_type} || 'memcached';
     my $subclass = __PACKAGE__."::".ucfirst($cache_type);
-    my $cache    = $subclass->_cache_handle(\%param)
+    my $cache    = $subclass->_cache_handle($param)
       or croak "Cannot create cache handle for '$cache_type'";
     return bless $class->SUPER::new({cache => $cache}), $subclass;              
 }
diff --git a/C4/Cache/Memcached.pm b/Koha/Cache/Memcached.pm
similarity index 95%
rename from C4/Cache/Memcached.pm
rename to Koha/Cache/Memcached.pm
index 1233d41..792b763 100644
--- a/C4/Cache/Memcached.pm
+++ b/Koha/Cache/Memcached.pm
@@ -1,4 +1,4 @@
-package C4::Cache::Memcached;
+package Koha::Cache::Memcached;
 
 # Copyright 2009 Chris Cormack and The Koha Dev Team
 #
@@ -23,14 +23,12 @@ use Carp;
 
 use Cache::Memcached;
 
-use base qw(C4::Cache);
+use base qw(Koha::Cache);
 
 sub _cache_handle {
     my $class  = shift;
     my $params = shift;
-
     my @servers = split /,/, $params->{'cache_servers'};
-
     return Cache::Memcached->new(
         servers   => \@servers,
         namespace => $params->{'namespace'} || 'KOHA',
@@ -40,6 +38,7 @@ sub _cache_handle {
 sub set_in_cache {
     my ( $self, $key, $value, $expiry ) = @_;
     croak "No key" unless $key;
+    $self->cache->set_debug;
 
     if ( defined $expiry ) {
         return $self->cache->set( $key, $value, $expiry );
diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index 128c9b2..87bbb1d 100755
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -328,4 +328,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OpacKohaUrl','1',"Show 'Powered by Koha' text on OPAC footer.",NULL,NULL);
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('EasyAnalyticalRecords','0','If on, display in the catalogue screens tools to easily setup analytical record relationships','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowRecentComments',0,'If ON a link to recent comments will appear in the OPAC masthead',NULL,'YesNo');
-
+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('usecache',0,'If on pages with caching enabled will use caching',NULL,'YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 0063a75..d2b4225 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -4550,6 +4550,12 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     print "Upgrade to $DBversion done Koha 3.6.0 release \n";
     SetVersion ($DBversion);
 }
+$DBversion = "3.06.00.xxx";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('usecache',0,'If on pages with caching enabled will use caching',NULL,'YesNo')");
+    print "Upgradet to $DBversion done (Added syspref usecache, When this preference is turned on pages with with caching support will use caching) \n";
+    SetVersion ($DBversion);
+}
 
 $DBversion = "3.06.00.001";
 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref
index f026c7e..e44af8d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref
@@ -94,4 +94,12 @@ Administration:
             - of CAS when logging out of Koha.
         -
             - The CAS Authentication Server can be found at
-            - pref: casServerUrl           
+            - pref: casServerUrl
+    Caching options:
+      -
+          - pref: usecache
+            default: 0
+            choices:
+              yes: Use
+              no: "Don't use"
+          - memcached caching
-- 
1.7.5.4


More information about the Patches mailing list