memcache 命令行操作整理

本文介绍了如何安装libevent及memcached,并通过示例展示了memcached的基本操作命令,包括数据的存储、获取、替换及增删等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  tar zxvf libevent-2.0.21-stable.tar.gz
 cd libevent-2.0.21-stable
 ./configure --prefix=/usr/local/libevent
  make
   make install
 

 tar zxvf memcached-1.4.32.tar.gz 
 cd memcached-1.4.32
 ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/
  make
  make install
 

 

链接命令行

telnet 127.0.0.1 1121

语法:add  key  flag  expire   length 回车

key 给值起一个独特的名字
flag 标志,要求为一个正整数
expire有效期
length 缓存的长度(字节为单位)

设置key值 的过期时间是30秒

set key  0 30 1
0
STORED
get key
VALUE key 0 1
0
END
incr key 1
1
get key
VALUE key 0 1
1
END
get key
VALUE key 0 1
1
END
get key
VALUE key 0 1
1
END

get key
END
 

 

数据存取
set key1 0 180 3
abc
STORED
add key1 0 180 3
xyz
NOT_STORED
get key1
VALUE key1 0 3
abc
END
replace key1 0 180 3
xyz
STORED
get key1
VALUE key1 0 3
xyz
END
delete key1
DELETED
数字加减
set key2 0 180
1234
STORED
incr key2 3
1237
get key2
VALUE key2 0
1237
END
decr key2 1
1236
get key2
VALUE key2 0
1236
END

转载于:https://my.oschina.net/yonghan/blog/758238

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值