memcached-cli - Interactive/Batch CLI for Memcached
Run an interactive CLI:
memcached-cli <HOST[:PORT] | /path/to/socket> [OPTIONS] memcached-cli --addr|-a <HOST[:PORT] | /path/to/socket> [OPTIONS] memcached-cli [OPTIONS] # Connect to 127.0.0.1:11211
These above turns into interactive mode like below:
memcached@SERVER:PORT> memcached@SERVER:PORT> set foo Foo OK memcached@SERVER:PORT> add bar Bar 300 OK memcached@SERVER:PORT> gets foo bar Key:foo Value:Foo Length:3B Flags:0 Cas:219 Key:bar Value:Bar Length:3B Flags:0 Cas:220 memcached@SERVER:PORT> \cd 1 # Alias of 'cachedump' Key:foo Value:Foo Length:3B Expire:2016-03-26 00:30:27 Flags:0 Cas:219 Key:bar Value:Bar Length:3B Expire:2016-03-26 09:53:19 Flags:0 Cas:220 Key:baz Value:Baz Length:3B Expire:2016-03-26 10:49:05 Flags:123 Cas:221 memcached@SERVER:PORT> delete foo OK memcached@SERVER:PORT> flush_all OK memcached@SERVER:PORT> \q # Quit interactive mode
Run as batch script:
memcached-cli [options] <command> [<args>]
Show Help/Manual:
# For general usage memcached-cli -h|--help memcached-cli --man # For available commands memcached@SERVER:PORT> help memcached@SERVER:PORT> help <command>
This script runs an interactive CLI or batch utility for Memcached.
In interactive mode, it connects to a specified Memcached server and interactively executes each command you run.
In batch mode, you can execute any command which you can do in interactive mode.
NOTE:
A couple of features of following commands derives from memcached/memcached-tool
Displays slabs statistics.
This command comes from memcached/memcached-tool.
Shows general statistics of memcached server by stats command. You can filter the parameters of stats by optional REGEXP argument.
stats
Comes from memcached/memcached-tool.
Shows memcached server settings by stats settings command. You can filter the parameters of stats by optional REGEXP argument.
stats settings
Comes from memcached/memcached-tool, too.
Shows detailed information including expiration times of some items in specified slab CLASS.
You can specify NUMBER of items to show. Without NUMBER option, shows 20 items only by default.
Reports statistics about data access using KEY prefix. The default separator for prefix is ':'.
If you have not enabled reporting at Memcached start-up, you can enable it by command detail on.
detail on
See man memcached(1) for details.
Enables or disables stats collection for stats detail dump reporting.
stats detail dump
MODE should be either "on" or "off" to enable or to disable.
Dumps whole data in Memcached server.
Recommended to use in batch mode like bellow:
memcached-cli SERVER:PORT dump_all > /path/to/dump.txt
Restore data from dump data file created by dump_all.
dump_all
Generates random sample data and SET all of them.
By default, it generates 100 data whose length is between 1B and 1000kB with prefix "memcached-cli:sample";
Gets items in memcached by specified KEYs and shows their data.
Gets items with CAS data in memcached by specified KEYs and shows their data.
Stores data into memcached by specified KEY, VALUE and optional EXPIRE and FLAGS.
Stores data into memcached by specified KEY, VALUE and optional EXPIRE and FLAGS only when there is NO data with the same KEY in the server.
Stores data into memcached by specified KEY, VALUE and optional EXPIRE and FLAGS only when there IS data with the same KEY in the server.
Appends VALUE after existing data in memcached which has specified KEY.
Puts VALUE before existing data in memcached which has specified KEY.
Stores data into memcached by specified KEY, VALUE and optional EXPIRE and FLAGS only when CAS of data is not changed from specified CAS value.
Update data expiration time with specified KEY and EXPIRE.
Add numeric VALUE for a data with specified KEY.
Subtract numeric VALUE from a data with specified KEY.
Deletes one item in memcached by specified KEY.
Invalidates all data in memcached by flush_all command.
flush_all
With DELAY option, invalidation is delayed for specified seconds.
See official documentation of memcached for details.
Executes any commands given as arguments.
With this command, you can execute any command against Memcached including what is not implemented as normal commands in this program.
Here are some examples:
> call stats conns > call slabs reassign 6 10 > call flush_all
LIMITATION:
Multi-lined queries like set are not supported.
set
Shows memcached server version.
Exits program in interactive mode.
Shows available COMMANDs and summary of their usage.
With optional COMMAND argument, shows detailed information of it.
Sets connection timeout. Default is 1 seconds.
Shows debug logs.
App::Memcached::CLI::Main, memcached(1), http://www.memcached.org/
IKEDA Kiyoshi <progrhyme@gmail.com>
Copyright (C) 2015-2017 IKEDA Kiyoshi.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. That means either (a) the GNU General Public License or (b) the Artistic License.
To install App::Memcached::CLI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Memcached::CLI
CPAN shell
perl -MCPAN -e shell install App::Memcached::CLI
For more information on module installation, please visit the detailed CPAN module installation guide.