17
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Memcachedで特定キーのキャッシュ有効期限を取得する

Posted at

kobitoのテストも兼ねて自分用にメモ。
かなり泥臭いけど。telnetでやるよりまし。

  1. slabidの一覧を取得

$ echo 'stats slabs' | nc {host} 11211

・・・
STAT 16:free_chunks 20
STAT 16:free_chunks_end 0
**STAT 17:chunk_size 4224**
STAT 17:chunks_per_page 248
STAT 17:total_pages 413
STAT 17:total_chunks 102424
STAT 17:used_chunks 93741
STAT 17:free_chunks 8683
STAT 17:free_chunks_end 0
STAT 18:chunk_size 5280
STAT 18:chunks_per_page 198
・・・

2. chunk_sizeを目安にslabidを決定し、item数を取得


	```
$ echo 'stats items' | nc {host} 11211 | grep "17:"

STAT items:17:number 93798
STAT items:17:age 614253
STAT items:17:evicted 75076
STAT items:17:outofmemory 0

  1. slab内のキー一覧からキーをgrep

$ echo 'stats cachedump 17 93798' | nc {host} 11211 | grep "{key_name}"

ITEM {key_name} [キャッシュサイズ b; キャッシュ有効期限 s]
\# 見つからなかった場合キャッシュキーが見つかるまでslabidを変えて2〜3を繰り返す

4. キャッシュ有効期限は unix timestamp 形式なので

	```
$ date -d @unix_timestamp

これで人間にもわかる表示になる

注意)consistent hashingで複数サーバにキャッシュしてる場合、一台ずつしらみつぶしにやらないといけないのでかなりしんどい

17
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?