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