memcache (using telnet operation)
1. How to use
1. Connect to Memcached
Telnet 192.168.1.100 11211
Add Name 0 60 5 [description Add is the name of the directive name is the key (is stored in key/value), 0 flags, 60 means that the data stored 60s 5 to put in much data], if a key already exists, and then put in is failed.
Get name [Gets the value of name]
Update
Set name 0 60 5 [if name this key exists, is updated, if key does not exist, it is added]
Delete
Delete key value
2. Common Commands
basic commands for memcached (installation, uninstall, startup, configuration related):
-P Listening Port
The IP address of the-l connection, the default is native
-D Start memcached service
-D Restart Restart memcached service
-D Stop|shutdown shut down the running memcached service
-D Install installation memcached service
-d Uninstall Uninstall memcached service
-U Run as (only valid when run as root)
-m maximum memory usage, in MB. Default 64MB
-Returns an error when M memory is exhausted instead of deleting the item
-C Maximum Simultaneous connection number, default is 1024
-F Block size growth factor, default is 1.25
-N Minimum allocation space, key+value+flags default is 48
-H Display Help
Basic commands for memcached (when memcached is started for commands that relate to the data that Memcached manages and its own running state):
Command |
Description |
Example |
Get |
Reads a value |
Get MyKey |
Set |
Set a key unconditionally |
Set MyKey 0 60 5 |
Add |
ADD a new key |
Add Newkey 0 60 5 |
Replace |
Overwrite existing Key |
Replace key 0 60 5 |
Append |
Append data to existing key |
Append key 0 60 15 |
Prepend |
Prepend data to existing key |
Prepend Key 0 60 15 |
incr |
Increments numerical key value by given number |
INCR MyKey 2 |
Decr |
Decrements numerical key value by given number |
DECR MyKey 5 |
Delete |
Deletes an existing key |
Delete MyKey |
Flush_all |
Invalidate specific items immediately |
Flush_all |
Invalidate all items in n seconds |
Flush_all 900 |
Stats |
Prints General statistics |
Stats |
Prints Memory statistics |
Stats Slabs |
Prints Memory statistics |
Stats malloc |
Print Higher level allocation statistics |
Stats items |
|
Stats Detail |
|
Stats sizes |
Resets statistics |
Stats Reset |
Version |
Prints server version. |
Version |
Verbosity |
Increases log level |
Verbosity |
Quit |
Terminate Telnet session |
Quit |
Keywords for viewing information in Chinese and English tables
Pid |
Memcache The process ID of the server |
Uptime |
Number of seconds the server has been running |
Time |
Server's current UNIX timestamp |
Version |
Memcache version |
Pointer_size |
The current operating system pointer size (32-bit system is typically 32bit) |
Rusage_user |
Cumulative user time for the process |
Rusage_system |
Cumulative system time of the process |
Curr_items |
The number of items currently stored by the server |
Total_items |
Total number of items stored since server startup |
bytes |
The number of bytes consumed by the current server storage items |
Curr_connections |
The number of connections currently open |
Total_connections |
Number of connections that have been opened since the server was started |
Connection_structures |
Number of connection constructs that the server assigns |
Cmd_get |
Get command (gets) the total number of requests |
Cmd_set |
Set command (save) number of total requests |
Get_hits |
Total Hit Count |
Get_misses |
Total missed Hits |
Evictions |
Number of items deleted to get free memory (the space allocated to memcache needs to be removed from the old items to get space allocated to new items) |
Bytes_read |
Total Read bytes (number of bytes requested) |
Bytes_written |
Total Bytes sent (result bytes) |
Limit_maxbytes |
Size of memory allocated to Memcache (bytes) |
Threads |
Current number of threads |
Special attention:If your site needs more than 64m of memcached memory, you should start this way
Memcached–m 256m–d Start
If the memory used by memcached exceeds the defined memory, the most infrequently used memory is removed, and the algorithm is LRU
If you want to change a port
Memcached-d-M 30-l 127.0.0.1-p 9000-d start this command does not work with UNIX