非常簡單,首先是在本機安裝memcache服務並啟動,
d:\memcached\memcached.exe -d install #安裝
d:\memcached\memcached.exe -d start #啟動
如果沒有在啟動時配置參數,默認端口則為11211
接着下載 memcache python版client
#coding=utf8 import memcache mcache= memcache.Client(['127.0.0.1:11211']) print mcache.set('say','hello,memcache') #display - True value = mcache.get('say') print value #display - hello,memcache
更詳細文檔在這里
https://developers.google.com/appengine/docs/python/memcache/
附上啟動參數說明:
-d 選項是啟動一個守護進程
-m 是分配給Memcache使用的內存數量,單位是MB,默認64MB
-M return error on memory exhausted (rather than removing items)
-u 是運行Memcache的用戶,如果當前為root 的話,需要使用此參數指定用戶
-l 是監聽的服務器IP地址,默認為所有網卡
-p 是設置Memcache的TCP監聽的端口,最好是1024以上的端口
-c 選項是最大運行的並發連接數,默認是1024
-P 是設置保存Memcache的pid文件