Memcached Study Notes

Source: Internet
Author: User

Recently, want to see the open source of things, just on the internet to see memcached this server, simply learned. Take a note!

1.memcached Introduction

Memcached I originally thought is a database software, but detailed understanding only then found, accurate is a server software, in recent years memcached always be said to be eliminated, by Redis overtook, but I think they each have their own advantages, or is worth to understand.

Memcached is a free && open source, high performance, distributed memory object cache system, the old NoSQL application, the general purpose is to reduce the number of database access by caching database query results, so as to improve the speed of dynamic Web applications and improve the scalability.

  NoSQL: (not only SQL), translating into plain English is more than just a relational database.

The notable feature of Memocached is that it is stored based on Key-value key value pairs, and Redis is stored based on key-value pairs, as well as in document-based storage: MongoDB;

2.memchached Start-up

  (1) Start under Windows

We can download the latest version of memcached on the official website and put it in a folder (because the software is very small), so we don't have to install it. Open the DOS window, switch to the folder where the software is stored, enter

>memcached.exe-m 64-p 11211-vvv can start memcched. The parameters are not described here, and can be queried by the-HELP option. is also relatively simple.

In general, we connect the memcached via Telnet. We want to open Telnet under Windows. In the Control Panel , find the option to turn windows on or off , tick the telnet Server and telnet client options, Click Confirm. <memcached client-to-server connection based on text protocol, not binary protocol >

Turn on Telnet;

>telnet (IP) (port number)

We can press "Ctrl +" to see the Echo function, enter the view;

  (2) booting under Linux

Booting under Linux is also handy. Download the latest version of the. tar.gz file on the official website. Unzip, compile the connection, run can. is our usual./configure--prefix= () && make &&make Install

You can then run it with the command above. (It's not too much to introduce here.)

  3.memcached Command Introduction

  (1)add command

    Syntax: Add key flag expire length

   Key: That is what we say in the Key-value value, in fact, is to give value a unique name;

flag: An integer that represents a rule. Usually we take 0;

expire: Indicates the validity period (stored in memory in the amount of time, generally in seconds), if 0, indicating that does not automatically expire, will remain 30 days, if not shut down the case;

Length: The size of the cache (in bytes);

Example: Add book 0 0 5

>hello

STORED

(2)get command < find >

Syntax: Get key

    Warning: When using Add, only key does not exist to be established, but for replace, only key exists to modify!

(3)Replace command < modify >

    Parameters, like the Add command, are actually modifying the value

(4) Delete command

Syntax: Delete key [number] (where this number indicates that you need to wait n seconds before you can use this key again, because you just deleted, you need to let the page cache metabolism complete)

(5) set command < equivalent combination of Add and Repalce >

    If the server does not have this key, then add up;

If the server has this key, it can be modified;

The syntax of set is the same as the add syntax;

(6) incr <increase, Growth >

    Syntax: incr key num (where NUM represents the increased number)

(7) DECR <decrease, reduce >

    Syntax: DECR key num

Note: incr and DECR need to understand the value as an unsigned book, theoretically the worth of NUM is in the range (0, 2^32-1);

(8) Stats < statistics >

    View memory information, etc.

(9) Flush_all < empty all storage objects >

    Note that this command is used with caution!

  

Memcached Study Notes

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.