[Memcached] Telnet command

Source: Internet
Author: User
Tags cas

One: Connection command

cmd or person Linux execution under Windows

Telnet 127.0.0.1 11211 (if the error is "Telnet is not an internal or external command", there must be no Telnet client installed see below how to turn on Telnet client) 11

You can connect the memcached.

[[Email protected] ~]# telnet 127.0.0.1 11211Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is ' ^] '. 12341234
11

Execute quit to exit the connection.

Quitconnection closed by foreign host. [[email protected] ~]# 12341234
Two: Store command

Example:
1:set Add or edit

Set a 0 0 48888STORED 12341234

The above command means: set a=8888

When the data does not exist, you can execute the add command, if the data already exists, return not_stored

Add a 0 0 48888not_stored 12341234

2:get get

Get avalue a 0 48888END 12341234

3:delete Delete

Delete aDELETED1212
11
4:replace replacement
Replace a 0 0 49999STORED 123123

If key does not exist, the Echo
Not_stored

Three: Other commands

Flush_all Clear All Caches

--------------------------------------------------------------------------------------------------------------- ----------

--------------------------------------------------------------------------------------------------------------- ----------

About the error "Telnet is not an internal or external command" Workaround:

(Systems in Windows 7 or above)

There must be no Telnet client installed see below how to turn on the Telnet client

1. Open Control Panel > Add Remove Programs > Turn Windows features on or off > check "telnet client" to confirm;

2. No need to restart, run "telnet" or "Telnet 127.0.0.1:11211" again

Note: Turning off the Telnet client will not take effect until it restarts.

--------------------------------------------------------------------------------------------------------------- ----------

--------------------------------------------------------------------------------------------------------------- ----------

A. Storage command

Format of the stored command:

<command name> <key> <flags> <exptime> <bytes><data block>

Parameter description:

TR style= "margin-left:30px;" >
<command name> operations Command: Set/add/replace
<KEY>
<FLAGS>
<EXPTIME>
cache The number of bytes of the value
<data block> data block

1. Add Value command

(1) Either add or update the SET command (the value does not exist, then update) the set setting can be used to get the value with the Get command, or you can use the Delete command to delete the value

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

[[Email protected]]# 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

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

(2) Add command that adds a value only if the data does not exist

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

[[Email protected]]# telnet 127.0.0.1 11211Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is ' ^] '. Add Zhang 0 0 1//First time Add success Q storedadd Zhang 0 0 1//second add failed qnot_stored

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

(3) Replace command only if data is present

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

[[Email protected]]# telnet 127.0.0.1 11211Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is ' ^] '. Replace Zha  ng_t 0 0 2//replace non-existent element failed 22not_storedadd zhang_t 0 0 212STOREDget zhang_tvalue zhang_t 0 212ENDreplace zhang_t 0 0 3//replace Existing value succeeds 200STOREDget zhang_t//value is replaced by zhang_t 0 3200END

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

2. Deleting a command delete

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

Get zhang_tvalue zhang_t 0 3200ENDdelete zhang_tdeletedget zhang_tend

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

Two read commands

1.get command gets the value of a key or multiple keys multiple keys separated by a space

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

Get zhang_t zhangvalue Zhang 0 1qENDset zhang_t 0 0 3100STOREDget zhang_t zhangvalue zhang_t 0 3100VALUE Zhang 0 1qEND

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

2. Get command more than the value returned by a number to determine whether the data has changed

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

Gets zhang_t zhangvalue zhang_t 0 4 1851000VALUE Zhang 0 1 181qENDset zhang_t 0 41000STOREDgets zhang_t zhangvalue zhan g_t 0 4 1861000VALUE Zhang 0 1 181qEND

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

3. CAs means check and set meaning, only if the last parameter that the crane gets to determine the value of the data changes in the same time will be stored successfully, otherwise return exists

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>


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


650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

4. Self-Reduction (INCR) (DECR) command

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

Set age 0 0 210STOREDget agevalue age 0 210ENDincr Age 212incr age 214get agevalue age 0 214ENDdecr age 113get Agevalue AG E 0 213END

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

Three-State command

1.stats Display MEMCACHD Status

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

statsstat pid 1532 //Process idstat uptime 348167 //Service run number of seconds stat time  1372215144 //Current UNIX timestamp stat version 1.4.14 //server version stat libevent 2.0.10-stable  stat pointer_size 32 //operating system word size stat rusage_user 3.997392 //process cumulative User Time STAT  rusage_system 2.258656 //process Cumulative system time stat curr_connections 5 //the number of currently open connections stat  total_connections 265 //Total Links stat connection_structures 7 //The number of link structures allocated by the server stat  reserved_fds 20 //stat cmd_get 1911 //Execute get command count stat cmd_set 195   Executes the set command number of times stat cmd_flush 3 //executes the flush command stat cmd_touch 0stat get_hits 1708  //get hit count Stat get_misses 203 //get misses Stat delete_misses 11 //delete   Misses Stat delete_hits 14 //delete hit count stat incr_misses 0  //incr  Self-increment command   number of misses stat incr_hits 0    //incr  hit count stat decr_misses 0  //decr   self-reduction   Number of misses stat decr_hits 0    //decr  hit count stat cas_misses 0    //cas  misses stat cas_hits 2     //case   hit count stat  cas_badval 1   //Use wipe count stat touch_hits 0stat touch_misses 0stat  auth_cmds 0stat auth_errors 0stat bytes_read 164108   //Read byte count stat  bytes_written 1520916 //Write byte book stat limit_maxbytes 67108864 //the amount of memory allocated stat  accepting_conns 1 //number of connections currently accepted stat listen_disabled_num 0stat threads 4 // Number of Threads stat conn_yields 0stat hash_power_level 16stat hash_bytes 262144stat  Hash_is_expanding 0stat expired_unfetched 4stat evicted_unfetched 0stat bytes  23995  //number of bytes stored in StAt curr_items 31 //item number Stat total_items 189 //item Total stat evictions 0  //the item number to get the space deleted Stat reclaimed 17end

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

2.flush_all emptying all items

Flush_allok

3. Subsequent append append and prepend front insert command

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

Get Agevalue Age 0 213ENDappend age 0 3ERRORappend age 0 0 6111111STOREDget agevalue age 0 813111111ENDprepend age 0 0 611 1111STOREDget agevalue Age 0 1411111113111111END

650) this.width=650; "alt=" Copy Code "src="/img/fz.gif "style=" border:0px; "/>

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

The command has an optional numeric parameter. It always executes successfully and the server sends a "ok\r\n" response. The effect is to invalidate an existing project immediately (the default), or after a specified time. After that the FETCH command is executed and nothing is returned (unless the same key name is re-stored). Flush_all actually does not immediately release the memory occupied by the project, but is executed later when new items are stored (this is determined by memcached's lazy detection and deletion mechanism).

The Flush_all effect is that it causes all items to be updated earlier than the time set by Flush_all, and the command is ignored when the FETCH command is executed.

Memecached There are other commands, this is just what we often use in our work, in this article to record the backup.


[Memcached] Telnet command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.