memcached 命令_Memcached Telnet命令示例

本文详细介绍了在MacOS和Unix系统上使用Memcached服务器的基本Telnet命令,包括如何检查服务器运行状况、存储和检索数据、管理缓存等,适用于任何安装了Telnet的操作系统。

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

memcached 命令

In earlier posts, we saw how to install Memcached server on Mac OS and Unix systems. After that we worked on to start Memcached server at boot time as a daemon process in Mac OS.

在之前的文章中,我们了解了如何在Mac OS和Unix系统上安装Memcached服务器。 之后,我们致力于在启动时启动Memcached服务器,作为Mac OS中的守护进程。

In this tutorial, we will go through some of the basic Memcached telnet commands that we can use to check the health of the Memcached server. These commands are very helpful in debugging purposes and can be used from any operating system with telnet installed.

在本教程中,我们将介绍一些基本的Memcached telnet命令,这些命令可用于检查Memcached服务器的运行状况。 这些命令对于调试目的非常有用,可以在安装了telnet的任何操作系统中使用。

If you are on a UNIX system, then using ps -eaf | grep memcached command will get you the port Memcached server is running on.

如果您在UNIX系统上,则使用ps -eaf | grep memcached ps -eaf | grep memcached命令将为您提供运行Memcached服务器的端口。

For example, when I run this command on my UNIX system, I got below output:

例如,当我在UNIX系统上运行此命令时,得到以下输出:

$ ps -eaf | grep memcached
503 55442 55296   0   0:00.15 ttys000    0:00.22 memcached -p 11111 -vv
503 58945 56875   0   0:00.01 ttys003    0:00.01 grep memcached
$

So Memcached server is running on TCP port 11111 and in verbose mode (-vv). If you want to run as daemon process then use -d option in the startup command.

因此,Memcached服务器在TCP端口11111上以详细模式( -vv )运行。 如果要作为守护进程运行,请在启动命令中使用-d选项。

Memcached Telnet命令 (Memcached Telnet Commands)

To connect to memcached server with telnet and start a session:

要使用telnet连接到memcached服务器并启动会话:

$ telnet localhost 11111

To store data in Memcached server with telnet:

要使用telnet将数据存储在Memcached服务器中:

set KEY META_DATA EXPIRY_TIME LENGTH_IN_BYTES

To retrieve data from Memcached through telnet:

要通过telnet从Memcached检索数据,请执行以下操作:

get KEY

To overwrite the existing key:

覆盖现有密钥:

replace KEY META_DATA EXPIRY_TIME LENGTH_IN_BYTES

To delete the key:

删除密钥:

delete KEY

To get the server statistics:

要获取服务器统计信息:

stats
stats items
stats slabs

To clear the cache data:

要清除缓存数据:

flush_all

To quit the telnet session:

退出telnet会话:

quit

Memcached服务器Telnet示例 (Memcached Server Telnet Example)

$ telnet localhost 11111
Trying ::1...
Connected to localhost.
Escape character is '^]'.
set Test 0 100 10
JournalDev
STORED
get Test
VALUE Test 0 10
JournalDev
END
replace Test 0 100 4
Temp
STORED
get Test
VALUE Test 0 4
Temp
END
stats items
STAT items:1:number 1
STAT items:1:age 19
STAT items:1:evicted 0
STAT items:1:evicted_time 0
STAT items:1:outofmemory 0
STAT items:1:tailrepairs 0
END
flush_all
OK
get Test
END
version
VERSION 1.2.8
quit
Connection closed by foreign host.
$

In the next post on memcached, I will provide information about using memcached client in Java.

在有关memcached的下一篇文章中,我将提供有关在Java中使用memcached客户端的信息。

Reference: Memcached Github Commands Page

参考: Memcached Github命令页面

翻译自: https://www.journaldev.com/16/memcached-telnet-commands-example

memcached 命令

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值