Distributed memcached Learning (2) & mdash; Basic memcached commands and basic memcached commands

Source: Internet
Author: User

Distributed memcached Learning (2) -- Basic memcached commands and basic memcached commands

The above section describes how to compile and log on to memcahed in linux. The following describes how to use the basic memcahed commands.

Add

Function: adds a new cache record to the memory.

Syntax: add key flag expire length

Resolution:

Key indicates a unique name for the value to be stored.

Flag, which must be a positive integer

The validity period of the expire cache record, in seconds. If it is set to 0, it will not automatically expire.

Length (in bytes)

For example:

 

 

Removable

 

Run add name 0 0 4. enter the value to be saved. After enter, the system prompts "stored", indicating that the storage is successful. We can use the get command to obtain this value:

 

 

Validity

 

The image is extracted successfully. If the validity period is set to 5 seconds, the value cannot be extracted after 5 seconds, as shown below:

 

 

Uniqueness

 

You cannot add an existing key to the memory. If a record whose key is name already exists, you cannot add another key. As follows:

 

 

 

 

Delete

Function: deletes a cache record from the memory.

Syntax: delete key

Resolution:

Key of the cache record to be deleted

For example:

 

Get

Function: extract a cache record from memory

Syntax: get key

Resolution:

Key of the cache record to be extracted

For example:

 

Replace

Function: replaces cache records in the memory.

Syntax: replace key flag expire length

Resolution:

Key of the cache record to be replaced

Flag, which must be a positive integer

The validity period of the expire cache record, in seconds. If it is set to 0, it will not automatically expire.

Length (in bytes)

For example:

 

It can be seen that the value of the record with the key of year is replaced with 2016.

 

Note: replace can be performed only when a key exists.

 

Set

Function: set or replace the cache records in the memory, which is equivalent to the add + replace function.

If this key is not in the server cache, a record is added. If the server has this key, the record is modified.

Syntax: set key flag expire length

Resolution:

Key of the cache record to be set or replaced

Flag, which must be a positive integer

The validity period of the expire cache record, in seconds. If it is set to 0, it will not automatically expire.

Length (in bytes)

For example:

 

Modify record

 

It can be seen that the value of the record with the key of year is replaced with 20160101.

 

Add record

 

 

It can be seen that the record whose key is date is added to the cache.

 

The basic commands of Memcached are learned here. Next we will discuss the memory management mechanism of Memcached.

 

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.