A storage command
Store command format:
<command name> <key> <flags> <exptime> <bytes> <data block>
Parameter Description:
<command name> | Operation command: set / add / replace |
<key> | Cache key |
<flags> | The client uses it to store additional information about the key-value pairs |
<exptime> | Cache expiration time units is always stored as seconds 0 |
<bytes> | The number of bytes cached value |
<data block> | data block |
1. Add Value command
(1) are added or updated in any case set command (value added exists does not exist update) set after set value can be obtained using the get command can also use the delete command to delete the value
[root@zhz jiehun]# telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
set test_key 0 0 3
100
STORED
get test_key
VALUE test_key 0 3
100
END
delete test_key
DELETED
get test_key
END
add command (2) data is added only when the value does not exist
[Root @ ZHZ jiehun] # telnet 127.0.0.1 11211 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. zhang the Add 0 1 0 // add first success q STORED the Add zhang 0 1 0 // add a second failure q NOT_STORED
(3) replacing the data is present only replace command
[Root @ ZHZ jiehun] # telnet 127.0.0.1 11211 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. replace zhang_t 0 0 2 // replace non-existent element failure 22 NOT_STORED add zhang_t 0 0 2 12 STORED get zhang_t VALUE zhang_t 0 2 12 END replace zhang_t value exists replace 0 0 3 // success 200 STORED get zhang_t // value is replaced VALUE zhang_t 0 3 200 END
2. Delete command to delete
get zhang_t VALUE zhang_t 0 3 200 END delete zhang_t DELETED get zhang_t END
Two read command
1.get command gets a key or more keys of the plurality of values separated by a space key
get zhang_t zhang VALUE zhang 0 1 q END set zhang_t 0 0 3 100 STORED get zhang_t zhang VALUE zhang_t 0 3 100 VALUE zhang 0 1 q END
Whether 2 .gets command for one more than the digital value judgment data through return get changed
gets zhang_t zhang VALUE zhang_t 0 4 185 1000 VALUE zhang 0 1 181 q END set zhang_t 0 29 4 1000 STORED gets zhang_t zhang VALUE zhang_t 0 4 186 1000 VALUE zhang 0 1 181 q END
3. cas mean check and set meaning only when the crane gets to the last parameter to determine the value of the acquired data changes are the same success will be stored, otherwise exists
gets zhang
VALUE zhang 0 3 188
dff
END
cas zhang 0 0 3 189
kjf
EXISTS
cas zhang 0 0 3 188
kjf
STORED
gets zhang
VALUE zhang 0 3 189
kjf
END
4. Since has (incr) decrement (DECR) Command
set age 0 0 2 10 STORED get age VALUE age 0 2 10 END incr age 2 12 incr age 2 14 get age VALUE age 0 2 14 END decr age 1 13 get age VALUE age 0 2 13 END
Three-state command
1.stats status display memcachd
stats STAT pid 1532 // process id STAT uptime 348167 // service running in seconds STAT time 1372215144 // current unix timestamp STAT version 1.4.14 // server version STAT libevent 2.0.10-stable STAT pointer_size 32 // OS word size STAT rusage_user 3.997392 // user time cumulative process STAT rusage_system 2.258656 // process the cumulative system time STAT curr_connections 5 // currently open connections STAT total_connections 265 // total number of links STAT connection_structures 7 // number assigned by the server link structure STAT reserved_fds 20 // STAT cmd_get 1911 // get the number of command execution STAT cmd_set 195 // set command executions STAT cmd_flush 3 // flush command execution times STAT cmd_touch 0 STAT get_hits 1708 // get the number of hits STAT get_misses 203 // get misses STAT delete_misses 11 // delete misses STAT delete_hits 14 // delete the number of hits STAT incr_misses 0 // incr increment command misses STAT incr_hits 0 // incr number of hits STAT decr_misses 0 // decr decrement misses STAT decr_hits 0 // decr number of hits STAT cas_misses 0 // cas misses STAT cas_hits 2 // case number of hits STAT cas_badval 1 // number of times using the wiping STAT touch_hits 0 STAT touch_misses 0 STAT auth_cmds 0 STAT auth_errors 0 STAT bytes_read 164108 // number of bytes read STAT bytes_written 1520916 // byte write book STAT limit_maxbytes 67108864 // amount of memory allocated STAT accepting_conns 1 // number of connections currently accepted STAT listen_disabled_num 0 STAT threads 4 // number of threads STAT conn_yields 0 STAT hash_power_level 16 STAT hash_bytes 262144 STAT hash_is_expanding 0 STAT expired_unfetched 4 STAT evicted_unfetched 0 STAT bytes 23995 // number of bytes of storage STAT curr_items 31 // item number STAT total_items 189 // total item STAT evictions 0 // item number deleted for space STAT reclaimed 17 END
2.flush_all clear all items
flush_all OK
3. Follow prepend and append the front insertion command
get age VALUE age 0 2 13 END append age 0 3 ERROR append age 0 0 6 111111 STORED get age VALUE age 0 8 13111111 END prepend age 0 0 6 111111 STORED get age VALUE age 0 14 11111113111111 END
The command has an optional numeric parameter. It always succeeds, the server sends "OK \ r \ n" in response. Its effect is to make the project already exists failure immediately (default), or after a specified time. After retrieving command execution, there will not be anything to return (unless re-store the same key name). flush_all in fact did not immediately release the memory occupied by the project, but then one after another execution (which is determined by laziness detection and removal mechanism of the memcached) is stored when a new project.
flush_all effect is that it causes all updates earlier than the set time flush_all project, the command is ignored when the command is executed to retrieve.
Some, this article memecached There are other commands, but usually we work here often used in recording standby.