ubuntu下的Memcached安装与测试

ubuntu下的Memcached安装与测试

由于memcached依赖于libevent;因此,还需要安装libevent,命令如下:

sudo apt-get install libevent-dev

如果libevent无法直接安装,则到官网下载一个http://libevent.org

(base) root@ubuntu:/home/shaodi/Downloads/libevent-2.1.11-stable# ./configure
(base) root@ubuntu:/home/shaodi/Downloads/libevent-2.1.11-stable# make
(base) root@ubuntu:/home/shaodi/Downloads/libevent-2.1.11-stable# make install

查看是否安装成功
(base) root@ubuntu:/home/shaodi/Downloads/libevent-2.1.11-stable# ls -al /usr/local/lib | grep libevent

最后安装memcached

sudo apt-get install memcached

启动Memcached

(base) root@ubuntu:/home/shaodi/Downloads# memcached -m 64 -p 11211 -vv -u root

使用telnet测试Memcached

(base) shaodi@ubuntu:~$ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
set foo 0 0 3
bar
STORED
get foo
VALUE foo 0 3
bar
END

使用如下的命令连接上面刚启动的Memcached。

telnet localhost 11211
在控制台会看到如下的信息:

Trying 127.0.0.1...  
Connected to localhost.  
Escape character is '^]'. 

保存数据的命令格式如下

set foo 0 0 3
bar
如果保存成功,控制台会输出:STORED

获取数据的命令格式如下:

get foo

在控制台的输出信息为:

VALUE foo 0 3
bar
END
原文地址:https://www.cnblogs.com/huanyinglvtuan/p/12389606.html