I. Overview of memcached
Memcache (memory, Cache): A high-performance distributed Memory object caching system. By maintaining a huge hash table in memory. (Key=value)
Hash table
Key (Keys) |
Value (values) |
Var1 |
"123456" |
Var2 |
Array (' AB ', ' CD ') |
Var3 |
Object value |
Second, memcached installation (Windows)
1, download memcached software. Click to download >>
2, copy the memcached software to a directory, preferably in the PHP development environment directory, easy to manage.
3, into the Windows command console, enter the directory, install memcached.exe–d install [uninstall use memcached.exe-d Uninstall]
Note: You can use the memcached command directly in the command console by adding the directory where the memcached resides to the Path. For specific actions, please click to view similar operation steps.
4, Start/stop memcached service, memcached-d Start[stop]
If you start successfully, you can see in the service:
5, the default use of Memcached port is: 11211
Special Note: memcached The default boot maximum memory is M. If the required memcached memory is greater than 64M, you should start this way
Memcached–m 256m–d Start
iii. Basic command of memcached
Install, uninstall, start, configure related
-P Listening Port
The IP address of the-l connection, the default is native
-D Start memcached service
-D Restart Restart memcached service
-D Stop|shutdown shut down the running memcached service
-D Install installation memcached service
-d Uninstall Uninstall memcached service
-U Run as (only valid when run as root)
-m maximum memory usage, in MB. Default 64MB
-Returns an error when M memory is exhausted instead of deleting the item
-C Maximum Simultaneous connection number, default is 1024
-F Block size growth factor, default is 1.25
-N Minimum allocation space, key+value+flags default is 48
-H Display Help
iv. operation of Memcached
telnet localhost 11211--telnet memcached
Command |
Description |
Example |
Get |
Reads a value |
Get MyKey |
Set |
Set a key unconditionally |
Set MyKey 0 60 5 |
Add |
ADD a new key |
Add Newkey 0 60 5 |
Replace |
Overwrite existing Key |
Replace key 0 60 5 |
Append |
Append data to existing key |
Append key 0 60 15 |
Prepend |
Prepend data to existing key |
Prepend Key 0 60 15 |
incr |
Increments numerical key value by given number |
INCR MyKey 2 |
Decr |
Decrements numerical key value by given number |
DECR MyKey 5 |
Delete |
Deletes an existing key |
Delete MyKey |
Flush_all |
Invalidate specific items immediately |
Flush_all |
Invalidate all items in n seconds |
Flush_all 900 |
Stats |
Prints General statistics |
Stats |
Prints Memory statistics |
Stats Slabs |
Prints Memory statistics |
Stats malloc |
Print Higher level allocation statistics |
Stats items |
|
Stats Detail |
|
Stats sizes |
Resets statistics |
Stats Reset |
Version |
Prints server version. |
Version |
Verbosity |
Increases log level |
Verbosity |
Quit |
Terminate Telnet session |
Quit |