1. install memcached In Ubuntu. Use the Ubuntu Software Center in the graphic interface. Find memcached. Click install to automatically download and install memcached.
For more information, see install Memcached In Ubuntu.
After the installation is complete, enter the/usr/share/directory to find the memcached directory. After switching to the root user, run/usr/share/memcached/scripts/start-memcached to start memcached. Run the pstree command to check whether memcached is successfully started. If memcached is successfully started, the memcached process is displayed. 2. run the memcached command to write and query key-value pairs and run Ctrl + Alt + t in another window. Use telnet to connect to the local machine to test the memcached function. Note that the default port of memcached is 11211: grid @ slavenode2 :~ $ Telnet 127.0.0.1 11211 Trying 127.0.0.1... connected to 127.0.0.1.Escape character is '^]'. the connection is successful when you see the above display. You can test the write key-value pairs and query key-value pairs through the set and get commands: 1) the write key-value pair set li 0 0 3 varSTORED command explanation: set-Flag is used to specify whether to compress data, 0 does not compress, 1 compress-Expires specifies the data storage time, one method is the number of seconds (up to 30 days ), another type can be specified with a unix timestamp. 0 is the number of bytes that are valid for an unlimited period of time-Byte. 2) query the key-value pair get liVALUE li 0 3 varEND 3. other operations set counter 0 0 11 STOREDincr counter 1 // auto-incrementing 2get counterVALUE counter 0 12 ENDappend counter 0 0 4 // append testSTOREDget counterVALUE counter 0 52 testENDdelete counter // Delete the specified key value DELETED flush_all // clear all key-value pairs OKget counterEND