memcached를 이용하면서 데이터에 바로 접근해야 할 때가 있다.
이 글에선 telnet 을 이용해서 memcached를 접근하는 방법에 대해서 기재한다.
memcached 란?
범용 분산 캐시 시스템
외부 데이터 소스의 읽기 횟수를 줄이기 위해 데이터와 객체들을 RAM에 캐시에 처리함으로써 동적 데이터베이스 드리븐 웹사이트의 속도를 높이기 위해 사용됨
Telnet이란?
인터넷이나 로컬 영역 네트워크 연결에 쓰이는 네트워크 프로토콜
$ 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.
이런 식으로 사용하면 된다.
Command | Description | Example |
---|---|---|
get | Reads a value | get mykey |
set | Set a key unconditionally | set 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 |
add | Add a new key | add newkey 0 60 5 |
replace | Overwrite existing key | replace key 0 60 5 |
append | Append data to existing key | append key 0 60 15 |
prepend | Prepend data to existing key | prepend key 0 60 15 |
incr | Increments numerical key value by given number | incr mykey 2 |
decr | Decrements numerical key value by given number | decr mykey 5 |
delete | Deletes an existing key | delete mykey |
flush_all | Invalidate all items immediately | flush_all |
flush_all | Invalidate all items in n seconds | flush_all 900 |
stats | Prints general statistics | stats |
Prints memory statistics | stats slabs | |
Print higher level allocation statistics | stats malloc | |
Print info on items | stats items | |
stats detail | ||
stats sizes | ||
Resets statistics counters | stats reset | |
lru_crawler metadump | Dump (most of) the metadata for (all of) the items in the cache | lru_crawler metadump all |
version | Prints server version. | version |
verbosity | Increases log level | verbosity |
quit | Terminate session | quit |
telnet : https://ko.wikipedia.org/wiki/%ED%85%94%EB%84%B7
memcached : https://lzone.de/cheat-sheet/memcached