Bugzilla – Attachment 6354 Details for
Bug 7248
Caching for services
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Git format patch rather than diff
git-caching.patch (text/plain), 11.15 KB, created by
Chris Hall
on 2011-11-20 22:46:44 UTC
(
hide
)
Description:
Git format patch rather than diff
Filename:
MIME Type:
Creator:
Chris Hall
Created:
2011-11-20 22:46:44 UTC
Size:
11.15 KB
patch
obsolete
>From f4e815f62f7556331862cb9b6cc7272f84b7aef1 Mon Sep 17 00:00:00 2001 >From: Chris Hall <chrish@catalyst.net.nz> >Date: Mon, 21 Nov 2011 11:38:23 +1300 >Subject: [PATCH] Caching support and syspref > >--- > C4/Cache.pm | 83 -------------------- > C4/Cache/Memcached.pm | 76 ------------------ > Koha/Cache.pm | 82 +++++++++++++++++++ > Koha/Cache/Memcached.pm | 75 ++++++++++++++++++ > installer/data/mysql/updatedatabase.pl | 6 ++ > .../prog/en/modules/admin/preferences/admin.pref | 10 ++- > 6 files changed, 172 insertions(+), 160 deletions(-) > delete mode 100644 C4/Cache.pm > delete mode 100644 C4/Cache/Memcached.pm > create mode 100644 Koha/Cache.pm > create mode 100644 Koha/Cache/Memcached.pm > >diff --git a/C4/Cache.pm b/C4/Cache.pm >deleted file mode 100644 >index 151a3fa..0000000 >--- a/C4/Cache.pm >+++ /dev/null >@@ -1,83 +0,0 @@ >-package C4::Cache; >- >-# Copyright 2009 Chris Cormack and The Koha Dev Team >-# >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it under the >-# terms of the GNU General Public License as published by the Free Software >-# Foundation; either version 2 of the License, or (at your option) any later >-# version. >-# >-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >-# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License along >-# with Koha; if not, write to the Free Software Foundation, Inc., >-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >- >-=head1 NAME >- >-C4::Cache - Handling caching of html and Objects for Koha >- >-=head1 SYNOPSIS >- >- use C4::Cache (cache_type => $cache_type, %params ); >- >-=head1 DESCRIPTION >- >-Base class for C4::Cache::X. Subclasses need to provide the following methods >- >-B<_cache_handle ($params_hr)> - cache handle creator >- >-B<set_in_cache ($key, $value, $expiry)> >- >-B<get_from_cache ($key)> >- >-B<clear_from_cache ($key)> >- >-B<flush_all ()> >- >-=head1 FUNCTIONS >- >-=cut >- >-use strict; >-use warnings; >-use Carp; >- >-use base qw(Class::Accessor); >- >-use C4::Cache::Memcached; >- >-__PACKAGE__->mk_ro_accessors( qw( cache ) ); >- >-sub new { >- my $class = shift; >- my %param = @_; >- >- my $cache_type = $param{cache_type} || 'memcached'; >- my $subclass = __PACKAGE__."::".ucfirst($cache_type); >- my $cache = $subclass->_cache_handle(\%param) >- or croak "Cannot create cache handle for '$cache_type'"; >- return bless $class->SUPER::new({cache => $cache}), $subclass; >-} >- >-=head2 EXPORT >- >-None by default. >- >-=head1 SEE ALSO >- >-C4::Cache::Memcached >- >-=head1 AUTHOR >- >-Chris Cormack, E<lt>chris@bigballofwax.co.nzE<gt> >- >-=cut >- >-1; >- >-__END__ >diff --git a/C4/Cache/Memcached.pm b/C4/Cache/Memcached.pm >deleted file mode 100644 >index 1233d41..0000000 >--- a/C4/Cache/Memcached.pm >+++ /dev/null >@@ -1,76 +0,0 @@ >-package C4::Cache::Memcached; >- >-# Copyright 2009 Chris Cormack and The Koha Dev Team >-# >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it under the >-# terms of the GNU General Public License as published by the Free Software >-# Foundation; either version 2 of the License, or (at your option) any later >-# version. >-# >-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >-# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License along >-# with Koha; if not, write to the Free Software Foundation, Inc., >-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >- >-use strict; >-use warnings; >-use Carp; >- >-use Cache::Memcached; >- >-use base qw(C4::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', >- ); >-} >- >-sub set_in_cache { >- my ( $self, $key, $value, $expiry ) = @_; >- croak "No key" unless $key; >- >- if ( defined $expiry ) { >- return $self->cache->set( $key, $value, $expiry ); >- } >- else { >- return $self->cache->set( $key, $value ); >- } >-} >- >-sub get_from_cache { >- my ( $self, $key ) = @_; >- croak "No key" unless $key; >- return $self->cache->get($key); >-} >- >-sub clear_from_cache { >- my ( $self, $key ) = @_; >- croak "No key" unless $key; >- return $self->cache->delete($key); >-} >- >-sub flush_all { >- my $self = shift; >- return $self->cache->flush_all; >-} >- >-1; >-__END__ >- >-=head1 NAME >- >-C4::Cache::Memcached - memcached subclass of C4::Cache >- >-=cut >diff --git a/Koha/Cache.pm b/Koha/Cache.pm >new file mode 100644 >index 0000000..7d39c3d >--- /dev/null >+++ b/Koha/Cache.pm >@@ -0,0 +1,82 @@ >+package Koha::Cache; >+ >+# Copyright 2009 Chris Cormack and The Koha Dev Team >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+=head1 NAME >+ >+Koha::Cache - Handling caching of html and Objects for Koha >+ >+=head1 SYNOPSIS >+ >+ use C4::Cache (cache_type => $cache_type, %params ); >+ >+=head1 DESCRIPTION >+ >+Base class for C4::Cache::X. Subclasses need to provide the following methods >+ >+B<_cache_handle ($params_hr)> - cache handle creator >+ >+B<set_in_cache ($key, $value, $expiry)> >+ >+B<get_from_cache ($key)> >+ >+B<clear_from_cache ($key)> >+ >+B<flush_all ()> >+ >+=head1 FUNCTIONS >+ >+=cut >+ >+use strict; >+use warnings; >+use Carp; >+ >+use base qw(Class::Accessor); >+ >+use Koha::Cache::Memcached; >+ >+__PACKAGE__->mk_ro_accessors( qw( cache ) ); >+ >+sub new { >+ my $class = shift; >+ my $param = shift; >+ my $cache_type = $param->{cache_type} || 'memcached'; >+ my $subclass = __PACKAGE__."::".ucfirst($cache_type); >+ my $cache = $subclass->_cache_handle($param) >+ or croak "Cannot create cache handle for '$cache_type'"; >+ return bless $class->SUPER::new({cache => $cache}), $subclass; >+} >+ >+=head2 EXPORT >+ >+None by default. >+ >+=head1 SEE ALSO >+ >+C4::Cache::Memcached >+ >+=head1 AUTHOR >+ >+Chris Cormack, E<lt>chris@bigballofwax.co.nzE<gt> >+ >+=cut >+ >+1; >+ >+__END__ >diff --git a/Koha/Cache/Memcached.pm b/Koha/Cache/Memcached.pm >new file mode 100644 >index 0000000..792b763 >--- /dev/null >+++ b/Koha/Cache/Memcached.pm >@@ -0,0 +1,75 @@ >+package Koha::Cache::Memcached; >+ >+# Copyright 2009 Chris Cormack and The Koha Dev Team >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use strict; >+use warnings; >+use Carp; >+ >+use Cache::Memcached; >+ >+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', >+ ); >+} >+ >+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 ); >+ } >+ else { >+ return $self->cache->set( $key, $value ); >+ } >+} >+ >+sub get_from_cache { >+ my ( $self, $key ) = @_; >+ croak "No key" unless $key; >+ return $self->cache->get($key); >+} >+ >+sub clear_from_cache { >+ my ( $self, $key ) = @_; >+ croak "No key" unless $key; >+ return $self->cache->delete($key); >+} >+ >+sub flush_all { >+ my $self = shift; >+ return $self->cache->flush_all; >+} >+ >+1; >+__END__ >+ >+=head1 NAME >+ >+C4::Cache::Memcached - memcached subclass of C4::Cache >+ >+=cut >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 815a71d..49ef378 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -4549,6 +4549,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); >+} > > =head1 FUNCTIONS > >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.4.1 >
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 7248
:
6353
|
6354
|
6356
|
6359
|
6372
|
6771
|
6772
|
7342
|
7343
|
7366
|
7367
|
9348
|
9349
|
9352
|
9353
|
9360
|
9552
|
9553
|
9554
|
9555
|
9556
|
9567
|
9568
|
9569
|
9571