Memcached cli 접근하기

wonhee·2022년 5월 29일
0
post-thumbnail

memcached를 이용하면서 데이터에 바로 접근해야 할 때가 있다.

이 글에선 telnet 을 이용해서 memcached를 접근하는 방법에 대해서 기재한다.

memcached 란?
범용 분산 캐시 시스템
외부 데이터 소스의 읽기 횟수를 줄이기 위해 데이터와 객체들을 RAM에 캐시에 처리함으로써 동적 데이터베이스 드리븐 웹사이트의 속도를 높이기 위해 사용됨

Telnet이란?
인터넷이나 로컬 영역 네트워크 연결에 쓰이는 네트워크 프로토콜

Linux에서 telnet으로 memcached에 접속하는 명령어

$ telnet {host_number} {port_number}

# 따라서  실제 사용하려면

$ telnet localhost 11211
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

stats
STAT pid 1
STAT uptime 27934698
STAT time 1653828829
STAT version 1.6.6
END

quit
Connection closed by foreign host.

이런 식으로 사용하면 된다.


사용 가능한 명령어

CommandDescriptionExample
getReads a valueget mykey
setSet a key unconditionallyset mykey <flags> <ttl> <size>

Ensure to use \r\n als line breaks when using Unix CLI tools. For example

printf "set mykey 0 60 4\r\ndata\r\n" \| nc localhost 11211
addAdd a new keyadd newkey 0 60 5
replaceOverwrite existing keyreplace key 0 60 5
appendAppend data to existing keyappend key 0 60 15
prependPrepend data to existing keyprepend key 0 60 15
incrIncrements numerical key value by given numberincr mykey 2
decrDecrements numerical key value by given numberdecr mykey 5
deleteDeletes an existing keydelete mykey
flush_allInvalidate all items immediatelyflush_all
flush_allInvalidate all items in n secondsflush_all 900
statsPrints general statisticsstats
Prints memory statisticsstats slabs
Print higher level allocation statisticsstats malloc
Print info on itemsstats items
stats detail
stats sizes
Resets statistics countersstats reset
lru_crawler metadumpDump (most of) the metadata for (all of) the items in the cachelru_crawler metadump all
versionPrints server version.version
verbosityIncreases log levelverbosity
quitTerminate sessionquit

참고

telnet : https://ko.wikipedia.org/wiki/%ED%85%94%EB%84%B7
memcached : https://lzone.de/cheat-sheet/memcached

profile
unknown

0개의 댓글