set命令保存:保存成功返回STORED ,保存失败返回ERROR
set key flags exptime bytes [noreply]
value
set name 1 100 8
zhangsan //value
STORED //保存成功,ERROR保存失败
key:键值 key-value 结构中的 key,用于查找缓存值。
flags:可以包括键值对的整型参数,客户机使用它存储关于键值对的额外信息 。
exptime:缓存时间,以秒为单位,0 表示永远
bytes:缓存字节数
noreply(可选): 该参数告知服务器不需要返回数据
value:存储的值(始终位于第二行)(可直接理解为key-value结构中的value)
get命令获取值:get key
get name //获取命令
VALUE name 1 8 //返回结果
zhangsan
END
gets命令获取值:命令获取带有 CAS 令牌存 的 value(数据值) ,如果 key 不存在,则返回空。
gets key1 key2 key3 …
gets name //获取命令
VALUE name 1 8 10//返回结果
zhangsan
END
add保存:保存成功返回STORED ,保存失败返回NOT_STORED
add key flags exptime bytes [noreply]
value
add age 3 100 2
12
STORED //保存成功STORED ,保持失败NOT_STORED
获取值:get key
get age
VALUE age 3 2
12
END
replace替换命令:
replace key flags exptime bytes [noreply]
value
替换:
replace age 3 100 4
1111
STORED
STORED:保存成功后输出
NOT_STORED:该键在 Memcached 上不存在。
CLIENT_ERROR:执行错误。
append value(数据值) 后面追加数据命令
append key flags exptime bytes [noreply]
value
append:
append name 3 100 8
123
STORED
STORED:保存成功后输出
NOT_STORED:该键在 Memcached 上不存在。
CLIENT_ERROR:执行错误。
prepend value(数据值) 前加数据命令
append key flags exptime bytes [noreply]
value
append:
prepend name 3 100 8
123
STORED
STORED:保存成功后输出
NOT_STORED:该键在 Memcached 上不存在。
CLIENT_ERROR:执行错误。
delete删除:
delete key [noreply]
delete name
DELETED
DELETED:删除成功。
ERROR:语法错误或删除失败。
NOT_FOUND:key 不存在。
清理缓存命令:清理缓存中的所有 key=>value(键=>值) 对。该命令提供了一个可选参数 time,用于在制定的时间后执行清理缓存操作。
flush_all [time] [noreply]