[文章作者:张宴 本文版本:v1.0 最后修改:2008.11.30 转载请注明原文链接:http://blog.zyan.cc/post/384/]
首先,需要了解Memcached协议,如果不清楚可参考《Memcached 协议中英文对照》。
1、数据存储(假设key为zhangyan,value为12345)
2、数据取回(假设key为zhangyan)
12345
END
3、数值增加1(假设key为zhangyan,并且value为正整数)
4、数值减少3(假设key为zhangyan,并且value为正整数)
5、数据删除(假设key为zhangyan)
6、查看Memcached状态
STAT uptime 4120500
STAT time 1228021767
STAT version 1.2.6
STAT pointer_size 32
STAT rusage_user 433.463103
STAT rusage_system 1224.515845
STAT curr_items 1132460
STAT total_items 8980260
STAT bytes 1895325386
STAT curr_connections 252
STAT total_connections 547850
STAT connection_structures 1189
STAT cmd_get 13619685
STAT cmd_set 8980260
STAT get_hits 6851607
STAT get_misses 6768078
STAT evictions 0
STAT bytes_read 160396238246
STAT bytes_written 260080686529
STAT limit_maxbytes 2147483648
STAT threads 1
END
7、模拟top命令,查看Memcached状态:
或者
首先,需要了解Memcached协议,如果不清楚可参考《Memcached 协议中英文对照》。
1、数据存储(假设key为zhangyan,value为12345)
printf "set zhangyan 0 0 5\r\n12345\r\n" | nc 127.0.0.1 11211
STORED2、数据取回(假设key为zhangyan)
printf "get zhangyan\r\n" | nc 127.0.0.1 11211
VALUE zhangyan 0 512345
END
3、数值增加1(假设key为zhangyan,并且value为正整数)
printf "incr zhangyan 1\r\n" | nc 127.0.0.1 11211
123464、数值减少3(假设key为zhangyan,并且value为正整数)
printf "decr zhangyan 3\r\n" | nc 127.0.0.1 11211
123435、数据删除(假设key为zhangyan)
printf "delete zhangyan\r\n" | nc 127.0.0.1 11211
DELETED6、查看Memcached状态
printf "stats\r\n" | nc 127.0.0.1 11211
STAT pid 3025STAT uptime 4120500
STAT time 1228021767
STAT version 1.2.6
STAT pointer_size 32
STAT rusage_user 433.463103
STAT rusage_system 1224.515845
STAT curr_items 1132460
STAT total_items 8980260
STAT bytes 1895325386
STAT curr_connections 252
STAT total_connections 547850
STAT connection_structures 1189
STAT cmd_get 13619685
STAT cmd_set 8980260
STAT get_hits 6851607
STAT get_misses 6768078
STAT evictions 0
STAT bytes_read 160396238246
STAT bytes_written 260080686529
STAT limit_maxbytes 2147483648
STAT threads 1
END
7、模拟top命令,查看Memcached状态:
watch "printf 'stats\r\n' | nc 127.0.0.1 11211"
或者
watch "echo stats | nc 127.0.0.1 11211"
如何在memcached中保存文件?
例如:
cp -rf /var/www/images/* nc 127.0.0.1 11211
这样的,感谢!
请问下,如何向memcached中写入文件,就像是向某个目录中写入文件一样的?
例如:
cp -rf /var/www/images/ nc 127.0.0.1 11211
这样的实现,谢谢!
张宴大大帮看看,是哪里的问题?
function rscandir($base='', &$data=array()) {
$array = array_diff(scandir($base), array('.', '..'));
foreach($array as $value) :
if (is_dir($base.$value)) {
$data = rscandir($base.$value.'/', $data);
}
elseif (is_file($base.$value)) {
$rest = substr($value, -4);
if ((!strcmp($rest,'.jpg')) || (!strcmp($rest,'.png'))
|| (!strcmp($rest,'.gif')) ){
$data[] = $base.$value;
}
}
endforeach;
return $data;
}
$mylist=rscandir("/var/www/mysite");
$srch = array('/var/www/mysite');
$newval = array('');
$memcache_obj = memcache_connect("192.168.2.1", 11211);
while (list($key, $val) = each($mylist)) {
$url=str_replace($srch,$newval,$val);
echo "$key => $val -> ".filesize($val)."\n";
$value = file_get_contents($val);
memcache_add($memcache_obj, $url, $value, false, 0);
}
?>
万分感谢!
burberry uk
ralph lauren uk
tiffanys
gucci uk
louis vuitton sac
Louis Vuitton Neverfull