1. memcached Overview
Memcache (memory, cache): a high-performance distributed memory object cache system. Maintain a large hash table in the memory. (Key = value)
Hash table
Key) |
Value) |
Var1 |
"123456" |
Var2 |
Array ('AB', 'cd ') |
Var3 |
Object Value |
Ii. Install memcached (Windows)
1. Download The memcached software. Click to download>
2. Copy the memcached software to a directory, which is better to be stored in the PHP development environment directory for ease of management.
3. log on to the Windows command console, go to the directory, and install memcached.exe-D install [uninstall memcached.exe-D uninstall]
Note: After you add the directory where memcached is located to the path, you can directly use the memcached command in the command console. For more information, see the following procedure.
4. start/stop the memcached service, memcached-d start [stop]
If the startup is successful, you can see in the service:
5. The default port used by memcached is: 11211.
Note: by default, memcached has a maximum memory of 64 MB. If the memory of memcached is larger than 64 MB, it should be started like this
[Plain]View plaincopy
- Memcached-M 256 m-d start
III. Basic memcached commands
Installation, uninstallation, startup, and Configuration
-P listening port
-L connected IP address. The default value is local
-D start: Start the memcached service.
-D restart: restart the memcached service.
-D stop | Shutdown the running memcached Service
-D install the memcached Service
-D uninstall memcached Service
-U runs as the identity (only valid when running as root)
-MB maximum memory usage, in MB. The default value is 64 MB.
-An error is returned when M memory is used up, instead of deleting items.
-C: Maximum number of simultaneous connections. The default value is 1024.
-F block size growth factor, default value: 1.25
-N: minimum allocation space. The default value of key + value + flags is 48.
-H Show Help
4. Operate 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 |