Bugzilla – Attachment 55169 Details for
Bug 11921
Move memcached configuration back to koha-conf.xml
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11921: Restore memcached infos to koha-conf
Bug-11921-Restore-memcached-infos-to-koha-conf.patch (text/plain), 4.77 KB, created by
Jonathan Druart
on 2016-09-05 10:16:19 UTC
(
hide
)
Description:
Bug 11921: Restore memcached infos to koha-conf
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-09-05 10:16:19 UTC
Size:
4.77 KB
patch
obsolete
>From cd46c3063408559f52752255608f1c08880a4801 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 22 Jun 2016 16:53:32 +0100 >Subject: [PATCH] Bug 11921: Restore memcached infos to koha-conf > >MEMCACHED_SERVERS and MEMCACHED_NAMESPACE should be moved back to >koha-conf instead of an ENV var to let command line scripts use >the cache mechanism. > >TODO: >- Add the entries to koha-conf.xml >- Remove occurrences of MEMCACHED_SERVERS in package, apache and plack files >--- > C4/Context.pm | 77 +++++++++++++---------------------------------------------- > Koha/Cache.pm | 9 +++---- > 2 files changed, 19 insertions(+), 67 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index cb3c966..728964e 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -18,7 +18,7 @@ package C4::Context; > > use strict; > use warnings; >-use vars qw($AUTOLOAD $context @context_stack $servers $memcached $ismemcached); >+use vars qw($AUTOLOAD $context @context_stack $servers); > BEGIN { > if ($ENV{'HTTP_USER_AGENT'}) { > require CGI::Carp; >@@ -86,23 +86,6 @@ BEGIN { > $CGI::LIST_CONTEXT_WARN = 0; > } > } # else there is no browser to send fatals to! >- >- # Check if there are memcached servers set >- $servers = $ENV{'MEMCACHED_SERVERS'}; >- if ($servers) { >- # Load required libraries and create the memcached object >- require Cache::Memcached; >- $memcached = Cache::Memcached->new({ >- servers => [ $servers ], >- debug => 0, >- compress_threshold => 10_000, >- expire_time => 600, >- namespace => $ENV{'MEMCACHED_NAMESPACE'} || 'koha' >- }); >- # Verify memcached available (set a variable and test the output) >- $ismemcached = $memcached->set('ismemcached','1'); >- } >- > } > > use Encode; >@@ -242,38 +225,9 @@ Returns undef in case of error. > sub read_config_file { # Pass argument naming config file to read > my $koha = XMLin(shift, keyattr => ['id'], forcearray => ['listen', 'server', 'serverinfo'], suppressempty => ''); > >- if ($ismemcached) { >- $memcached->set('kohaconf',$koha); >- } >- > return $koha; # Return value: ref-to-hash holding the configuration > } > >-=head2 ismemcached >- >-Returns the value of the $ismemcached variable (0/1) >- >-=cut >- >-sub ismemcached { >- return $ismemcached; >-} >- >-=head2 memcached >- >-If $ismemcached is true, returns the $memcache variable. >-Returns undef otherwise >- >-=cut >- >-sub memcached { >- if ($ismemcached) { >- return $memcached; >- } else { >- return; >- } >-} >- > =head2 db_scheme2dbi > > my $dbd_driver_name = C4::Context::db_schema2dbi($scheme); >@@ -355,22 +309,23 @@ sub new { > return; > } > } >- >- if ($ismemcached) { >- # retrieve from memcached >- $self = $memcached->get('kohaconf'); >- if (not defined $self) { >- # not in memcached yet >- $self = read_config_file($conf_fname); >- } >- } else { >- # non-memcached env, read from file >+ >+ my $conf_cache = Koha::Caches->get_instance('config'); >+ if ( $conf_cache ) { >+ $self = $conf_cache->get_from_cache('kohaconf'); >+ } >+ unless ( %$self ) { > $self = read_config_file($conf_fname); > } >- >- $self->{"config_file"} = $conf_fname; >- warn "read_config_file($conf_fname) returned undef" if !defined($self->{"config"}); >- return if !defined($self->{"config"}); >+ if ( $conf_cache ) { >+ # FIXME it may be better to use the memcached servers from the config file >+ # to cache it >+ $conf_cache->set_in_cache('koha_conf', $self) >+ } >+ unless ( exists $self->{config} or defined $self->{config} ) { >+ warn "read_config_file($conf_fname) returned undef"; >+ return; >+ } > > $self->{"Zconn"} = undef; # Zebra Connections > $self->{"userenv"} = undef; # User env >diff --git a/Koha/Cache.pm b/Koha/Cache.pm >index 598c35b..ae451c2 100644 >--- a/Koha/Cache.pm >+++ b/Koha/Cache.pm >@@ -78,7 +78,7 @@ sub new { > $ENV{DEBUG} && carp "Default caching system: $self->{'default_type'}"; > > $self->{'timeout'} ||= 0; >- $self->{'namespace'} ||= $ENV{MEMCACHED_NAMESPACE} || 'koha'; >+ $self->{'namespace'} ||= $ENV{MEMCACHED_NAMESPACE} || C4::Context->config('memcached_namespace') || 'koha'; > $self->{namespace} .= ":$subnamespace:"; > > if ( $self->{'default_type'} eq 'memcached' >@@ -116,11 +116,8 @@ sub new { > > sub _initialize_memcached { > my ($self) = @_; >- my @servers = >- split /,/, $self->{'cache_servers'} >- ? $self->{'cache_servers'} >- : ($ENV{MEMCACHED_SERVERS} || ''); >- return if !@servers; >+ my @servers = split /,/, $ENV{MEMCACHED_SERVERS} || C4::Context->config('memcached_servers') || ''; >+ return unless @servers; > > $ENV{DEBUG} > && carp "Memcached server settings: " >-- >2.8.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 11921
:
54818
|
54819
|
54820
|
55169
|
55170
|
55171
|
55258
|
55259
|
55268
|
55269
|
55270
|
55271
|
55272
|
55310
|
55311
|
55312
|
55313
|
55314
|
55315
|
55441