Detailed access commands in the memcached

Source: Internet
Author: User
Tags cas memcached

This article and everyone to share is mainly memcached in the use of some of the use of Access commands related usage, a look at it, hope to learn memcached to help others.

  Store command

  Set: force the set operation Regardless of key existence or not;

  Add: The memcached must not exist in the corresponding key to function;

  Replace: Requires a corresponding key in the memcached must exist in order to function;

  Append: Appends data to the end of the key corresponding to value. (not allowed to exceed limit for managing list)

  CAS(Check and set): Another operation that stores data, the last time you read the data, no one else can write success until the data is modified. Used to resolve the competition when updating data.

Get command:

  Get: Gets The value of one key or more keys ;

  Gets: the get command with CAS returns a CAS ID (the only digits) of value.

  Delete: Delete the existing item

  INCR/DECR: Self-increment or self-reduction. Only positive integers are accepted. If key does not exist,incr/decr fails.

  Flush_all: Clears All items in the memcached, primarily by setting all data to expire, specifying an expiration time.

  Python client:python-memcached vs PYLIBMC(comparison of common client clients)

  Operation Demo

  python-memcached:pip install python-memcached// direct ann python-memcached

  PYLIBMC:

  sudo apt-get install Python-dev// first installed Python-dev

  Sudo apt-get Install Libmemcached-dev// Reinstall Libmemcached-dev

  Pip install PYLIBMC// installation client succeeded

  start the memcached service:python-memcached Operation Demo

If you do not set a parameter, the default is in all The IP address is started, the default port 11211

when you're done, you can manipulate the cache.

Enter the code base first, then activate the virtual cache and execute after activation

The introduction of Python-memcached Library, establish a connection with the server side, port number 11211, set up and can communicate with the cache server, set the cache, successful will return a True

Verify that the values are written in

self-increment, type int ,string all rows

Self-reduction

  PYLIBMC 's Operation Demo:

first introduce the PYLIBMC client library, and also establish a connection to the server side

Self-increment

Self-reduction

Delete

another way to assign values, delete, etc.

  Detailed Setup Commands:

original link:http://www.maiziedu.com/wiki/django/access/

Detailed access commands in the 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.