1. Install
sudo apt-get install memcached
2. Start and stop
Start: Service memcached start stop: Service memcached Stop Status: Service memcached status
3. Connection Memcached
Use the following method: Telnet IP port, eg:telnet 127.0.0.1 11211 to connect to the memcached server.
4. Some Command
Set 0 0 3 (Save command) bar (query data) STORED (result) Get 03 (data) bar (query data) quit (exit)
5. View memcached Status
Stats Command, the results are explained in detail:1. Process ID of the pid:memcached service process2. The time, in seconds, that the uptime:memcached service has elapsed from startup to current. 3. Time:memcached the time, in seconds, of the current system on which the server is hosted. 4. The version number of the version:memcached. 5. Pointer_size: The pointer size of the host operating system on which the server is located, typically 32 or.6. Curr_items: Represents the number of cached objects that are held in the current cache. Objects that are currently removed from the cache are not included. 7. Total_items: Represents the number of objects that have been stored by the system since the Memcached service was started to the current time, including objects that are currently removed from the cache. 8. Bytes: Represents the storage space used by the system to store cached objects in bytes. 9. Curr_connections: Indicates the number of connections that are open by the current system. Ten. Total_connections: Represents the total number of connections that have been opened by the system from the Memcached service startup to the current time. One. Connection_structures: Indicates the number of connection structures that have been allocated from the Memcached service to the current time, and this explanation is given in the Protocol document, and I do not understand it at this point. A. Cmd_get: The number of cumulative fetch data, here is 3, because I tested 3 times, the first time because there is no serialized object, so get data failed, is NULL, 2 times behind is I tested with different objects 2 times. -. Cmd_set: Cumulative number of saved data, here is 2. Although I have stored 3 times, but for the first time because there is no serialization, it is not saved to the cache, there is no record. -. Get_hits: Indicates the number of times the data was successfully obtained. the. Get_misses: Indicates the number of times the data failed to get. -the. EVICTIONS:LRU algorithm removes the number of objects used to free memory. -The total number of bytes read by the. bytes_read:memcached server from the network. -The total number of bytes sent by the. Bytes_written:memcached server to the network. +The maximum number of bytes allowed to be used by the limit_maxbytes:memcached service cache. Total amount of available storage space. Match the size of the Memcached service settings that we started. -. Threads: The total number of worker threads that are requested. This explanation is given in the protocol document, what exactly does it mean, I don't understand yet.
6. Management memcached
1. Manually start memcached memcached-d-m --L127.0.0.1-P11211-u root assigns 128M memory to root user to start memcache memcached-d-m --L127.0.0.1-P11212-u Root launches Another example of a memcache instance on another port 11212:/usr/local/bin/memcached-d-U nobody-m1024x768-P11210-L10.11.12.70-p/opt/memcached/pid/M11210.pid2. memcached main startup parameter start mode:-D run in daemon (daemon) mode-u root specify user, if current is root, need to use this parameter to specify user-p/tmp/A.pid Save the PID to the specified file memory settings:-M1024x768The amount of data memory, not including the memcached itself, in megabytes-M Not enough memory to prohibit LRU, error-N -Initial chunk=key+suffix+value+32 struct, default 48 bytes-F1.25Growth factor, default 1. --L enable large memory pages to reduce memory waste and improve performance connection settings:-L127.0.0.1Listening IP address, this parameter can not be set by this machine-P11211TCP port, default is 11211, can not be set-U11211UDP port, the default is 11211,0 to turn off the concurrency setting:-C1024x768Maximum number of concurrent connections, default 1024, preferably-T4number of threads, default 4. Since memcached uses NIO, more multithreading does not have much effect-R -Maximum number of concurrent connections per event, default-C Disable CAS command (can suppress version count, reduce overhead)
memcached Technical Support