1. start Memcache's common parameter-p & lt; num & gt; set the port number (default value: 11211)-U & lt; num & gt; UDP listening port (default value: -l & lt; ip_addr & gt; binding address (default: all allow, regardless of the intranet or Internet or local IP address, there is a security risk, if...
1. start common Memcache parameters
-P Set the port number (default value: 11211)
-U UDP listening port (default: 11211, disabled at 0)
-L Binding address (default: all allow, regardless of the intranet and internet or the local machine to change the IP address, there is a security risk, if set to 127.0.0.1, only local access is allowed)
-D independent process running
-U Bind to use the specified process for running
-M Maximum memory usage allowed, in MB (default: 64 MB)
-P Write PID to file In this way, the following process can be terminated quickly and must be used together with-d.
For example:
In linux:./usr/local/bin/memcached-d-u jb-mc-l 192.168.1.197-m 2048-p 12121
In the window: d: \ App_Serv \ memcached \ memcached.exe-d RunService-l 127.0.0.1-p 11211-m 500
Register as a service in windows and run:
SC .exe create jb-Memcached binpath = "d: \ App_Serv \ memcached \ memcached.exe-d RunService-p 11211-m 500" start = auto
Net start jb-Memcached
2. connection: telnet 127.0.0.1 11211
3. you will use five basic memcached commands to perform the simplest operations. These commands and operations include:
Set: used to add a new key-value pair to the cache. If the key already exists, the previous value is replaced.
Add: the add command adds a key-value pair to the cache only when the key does not exist in the cache. If a key already exists in the cache, the previous values remain the same and you will get the response NOT_STORED.
Replace: the replace command replaces the cached key only when the key already exists. If no key exists in the cache, you will receive a NOT_STORED response from the memcached server.
Get: used to retrieve values related to previously added key-value pairs.
Delete: delete any existing values in memcached. You will use a key to call delete. if the key exists in the cache, the value is deleted. If not, a NOT_FOUND message is returned.
Gets: similar to basic get commands. The difference between the two commands is that gets returns a little more information: The 64-bit integer value is very similar to the "version" identifier of the name/value pair.
The first three commands are standard modification commands used to operate key-value pairs stored in memcached. They are both very easy to use and all use the syntax shown in listing 5:
Command
Table 1. modify command parameters of memcached
Parameter usage
Key is used to find the cache value.
Flags can include an integer parameter of a key-value pair. the client uses it to store additional information about the key-value pair.
Expiration time the length of time when the key-value pair is saved in the cache (in seconds, 0 indicates permanent)
Bytes stored in the cache
Example of the value stored by value (always in the second row:
Set useID 0 0 5
1234
4. cache management commands
The last two memcached commands are used to monitor and clear memcached instances. They are stats and flush_all commands.
Stats: dump the current statistics of the connected memcached instance.
Flush_all: used to clear all name/value pairs in the cache. If you need to reset the cache to a clean state, flush_all can be of great use.
Run the following command to view the memcached status:
STAT pid 22459 process ID
STAT uptime 1027046 server running seconds
STAT time 1273043062 server current unix timestamp
STAT version 1.4.4 server version
STAT pointer_size 64 OS font size (this server is 64-bit)
STAT rusage_user 0.040000 cumulative process user time
STAT rusage_system 0.260000 cumulative system time of processes
STAT curr_connections 10 number of currently opened connections
STAT total_connections 82 total number of connections opened
STAT connection_structures 13 Number of connection structures allocated by the server
STAT cmd_get 54 total number of get commands executed
STAT cmd_set 34 total number of set commands executed
STAT cmd_flush 3 points to the total number of flush_all commands
STAT get_hits 9 get hits
STAT get_misses 45 get Miss times
STAT delete_misses 5 delete Miss times
STAT delete_hits 1 delete hits
STAT incr_misses 0 incr Miss count
STAT incr_hits 0 incr hits
STAT decr_misses 0 decr Miss count
STAT decr_hits 0 decr hits
STAT cas_misses 0 cas Miss count
STAT cas_hits 0 cas hits
STAT cas_badval 0 used for wiping
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 15785 total number of bytes read
STAT bytes_written 15222 total number of written bytes
STAT limit_maxbytes 1048576 memory allocated (bytes)
STAT accepting_conns 1 currently accepted connections
STAT listen_disabled_num 0
STAT threads 4 threads
STAT conn_yields 0
STAT bytes 0 stores item bytes
STAT curr_items 0 item count
STAT total_items 34 total items
STAT evictions 0 indicates the total number of items deleted from the retrieved space.
From iloveyin