Install:
1. Download Memcache.zip. in the attachment. Unzip it on the D drive, such as D:/memcache
2. Open cmd and enter the memcache of the D drive.
Several commands commonly used by MemCache:
Install: memcache.exe -d install
Uninstall: memcache.exe -d uninstall
Start: memcache.exe -d start
Stop: memcache.exe -d stop
The default port of memcache is 11211, and the default memory size is 64M. If you need to modify these two parameters, use the following command:
memcache.exe -p 10000 -m 512 -d start
specification:
-p listen port
-l The IP address of the connection, the default is the local machine
-d start start the memcached service
-d restart restart memcached service
-d stop|shutdown Shut down the running memcached service
-d install install memcached service
-d uninstall uninstalls the memcached service
-u run as (only valid when running as root)
-m Maximum memory usage, in MB. Default 64MB
-M returns an error when memory is exhausted instead of deleting items
-c The maximum number of simultaneous connections, the default is 1024
-f block size growth factor, default is 1.25
-n Minimum allocation space, key+value+flags defaults to 48
-h show help
Operating the MemCached service in the terminal
Connect to Memcache console: telnet ServerIP 11211
Print the current Memcache server status: stats
stats statistics detailed description:
Print the statistics of the current Memcache server Items (records): stats items
Print the statistics of the current Memcache server Slab (partition) and Chunk (block): stats slabs
打印指定Slab中的KEY列表(可用于遍历items,但效率较低,慎用!):stats cachedump SlabId Limit_num。显示结果:ITEM KeyName [ValueByteLength b; LastAccessTime s]。值得注意的是,经过测试确认:那个LastAccessTime并不是记录到期时间,而是最后一次的get时间,并且get之后,也不会自动延长expiry(到期时间)。
添加新记录:add KeyName 0 0 ValueByteLength [回车] ValueContent,其中第一个0是一个flag标志位,可以存储本条数据的一些额外数据,第二个0是数据过期时间,单位秒,0表示永不过期,下同
删除记录 : delete KeyName
添加或更新记录 : set KeyName 0 0 ValueByteLength [回车] ValueContent
更新记录 : replace KeyName 0 0 ValueByteLength [回车] ValueContent
说明:add只有在key不承在时起作用,replace只有在key承在时起作用,而set则是当key不承在时执行add,key承在时执行replace。