Bugzilla – Attachment 102994 Details for
Bug 25158
Introduce koha-memcached
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25158 - Introduce koha-memcached
Bug-25158---Introduce-koha-memcached.patch (text/plain), 4.20 KB, created by
Magnus Enger
on 2020-04-15 12:33:22 UTC
(
hide
)
Description:
Bug 25158 - Introduce koha-memcached
Filename:
MIME Type:
Creator:
Magnus Enger
Created:
2020-04-15 12:33:22 UTC
Size:
4.20 KB
patch
obsolete
>From f1f307885e997c4f62c6e7d9018e3aec48db78ab Mon Sep 17 00:00:00 2001 >From: Magnus Enger <magnus@libriotech.no> >Date: Wed, 15 Apr 2020 14:30:12 +0200 >Subject: [PATCH] Bug 25158 - Introduce koha-memcached > >Introducing a proof of concept koha-memcached script. See Bugzilla >for more on the background. > >To test: Run the script with --help to see the available options, >then play around with them in a testing environment to see if they >work as they should, without unexpected sideeffects. >--- > debian/scripts/koha-memcached | 115 ++++++++++++++++++++++++++++++++++ > 1 file changed, 115 insertions(+) > create mode 100644 debian/scripts/koha-memcached > >diff --git a/debian/scripts/koha-memcached b/debian/scripts/koha-memcached >new file mode 100644 >index 0000000000..f297009f79 >--- /dev/null >+++ b/debian/scripts/koha-memcached >@@ -0,0 +1,115 @@ >+#!/usr/bin/perl >+# koha-memcached -- interact with items stored in memcached >+# Copyright 2020 Libriotech AS >+# >+# This program 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 3 of the License, or >+# (at your option) any later version. >+# >+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>. >+ >+use Memcached::libmemcached qw( memcached_create memcached_server_add memcached_get memcached_delete ); >+use Data::Dumper; >+use Getopt::Long; >+use Modern::Perl; >+ >+Getopt::Long::Configure("bundling"); >+ >+my %opts; >+my $res = GetOptions( \%opts, >+ "list|l=s", >+ "get|g=s", >+ "delete|d=s", >+ "help|h", >+); >+ >+if ( !$res || $opts{help} ) { >+ show_help( !$res ); >+ exit( !$res ); >+} >+ >+if ( !@ARGV ) { >+ show_help( 1, "An instance name must be supplied." ); >+ exit(1); >+} >+my $instance = shift @ARGV; >+if ( !-e "/etc/koha/sites/$instance" ) { >+ show_help( 1, "The instance doesn't exist: $instance" ); >+ exit(1); >+} >+ >+my $memc = memcached_create(); >+memcached_server_add( $memc, "localhost", '11211' ); # FIXME Get this from koha-conf.xml >+ >+if ( defined $opts{list} ) { >+ >+ if ( $opts{list} eq 'all' ) { >+ say sort `memcdump --servers=localhost | grep "koha_$instance"`; >+ } elsif ( $opts{list} eq 'authval' ) { >+ say sort `memcdump --servers=localhost | grep "koha_$instance" | grep "::AuthorisedValues"`; >+ } elsif ( $opts{list} eq 'syspref' ) { >+ say sort `memcdump --servers=localhost | grep "koha_$instance" | grep "syspref:syspref"`; >+ } >+ >+} elsif ( defined $opts{get} ) { >+ >+ $opts{get} = expand_shortcut( $opts{get}, $instance ); >+ say memcached_get( $memc, $opts{get} ); >+ >+} elsif ( defined $opts{delete} ) { >+ >+ $opts{delete} = expand_shortcut( $opts{delete}, $instance ); >+ memcached_delete( $memc, $opts{delete} ); >+ >+} >+ >+sub expand_shortcut { >+ >+ my ( $string, $instance ) = @_; >+ >+ my %shortcut = ( >+ 'config' => "koha_$instance:config:koha_conf", >+ ); >+ >+ if ( defined $shortcut{ $string } ) { >+ return $shortcut{ $string }; >+ } else { >+ return $string; >+ } >+ >+} >+ >+sub show_help { >+ my ( $err, $msg ) = @_; >+ >+ my $fh = $err ? *STDERR : *STDOUT; >+ say $fh "Error: " . $msg if $msg; >+ print $fh $_ while <DATA>; >+} >+ >+__DATA__ >+koha-memcached -- interact with items stored in memcached >+ >+Usage: koha-memcached [options] [instance name] >+ >+Options: >+ -l, --list TYPE list all KEYS of type TYPE (all, syspref, authval) >+ -g, --get KEY display the value associated with a KEY >+ -d, --delete KEY delete the value for a given KEY >+ -h, --help show this help and quit >+ >+Possible values for TYPE: >+ all = display all KEYS >+ syspref = display KEYS for all systempreferences >+ authval = display KEYS for all authorised values >+ other = all keys that are not in the specific categories above (not implemented) >+ >+Special values/shortcuts for KEY: >+ config = the configuration from koha-conf.xml >-- >2.17.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 25158
: 102994