Memcac..._stats(3pm)
β¨ NAME β¨
memcached_stat, memcached_stat_servername, memcached_stat_get_value, memcached_stat_get_keys β bestie, we're getting memcached statistics π
(also hi, you're on the Memcac..._stats(3pm) page, welcome, come sit with me π«Ά)
π LIBRARY
The C Client Library for memcached β aka libmemcached, link it with -lmemcached π₯
π SYNOPSIS π
#include <memcached.h>
memcached_stat_st *memcached_stat (memcached_st *ptr,
char *args,
memcached_return_t *error);
memcached_return_t memcached_stat_servername (memcached_stat_st *stat,
char *args,
const char *hostname,
unsigned int port);
char *
memcached_stat_get_value (memcached_st *ptr,
memcached_stat_st *stat,
const char *key,
memcached_return_t *error);
char **
memcached_stat_get_keys (memcached_st *ptr,
memcached_stat_st *stat,
memcached_return_t *error);
πΈ DESCRIPTION πΈ
okay so. libmemcached(3) can literally go ask a memcached server (or a whole lil collection of servers) what its current state is. Those state queries hand you back a memcached_stat_st structure. And bestie, you are responsible for freeing that structure. π
So yeah, technically you could just reach into the struct and grab stuff directly β but it is not advisable. memcached_stat_get_value() has been provided to query the structure, so use that, okay? π
π¦ memcached_stat()
memcached_stat() fetches an array of memcached_stat_st structures holding the state of all available memcached servers. The return value must be freed by the calling application β that's on you, not me, not the library. π«Ά
And listen: if you call it with the MEMCACHED_BEHAVIOR_USE_UDP behavior set, a NULL value is returned and the error parameter gets set to MEMCACHED_NOT_SUPPORTED. That's just how it is, no cap.
π memcached_stat_servername()
memcached_stat_servername() can be used standalone, without a memcached_st, to obtain the state of one particular server. β¨
args is what defines a particular state object β and heads up, a list of these is not provided for by the memcached_stat_get_keys() call, nor are they defined in the memcached protocol. So don't come looking for a cheat sheet, it's not there. π
You must specify the hostname and port of the server you want info on.
π memcached_stat_get_value()
memcached_stat_get_value() returns the value of a particular state key. You specify the key you wish to obtain. The key must be null terminated. periodt.
β memcached_stat_get_keys()
memcached_stat_get_keys() returns a list of keys that the server has state objects on. You are responsible for freeing this list. (see the pattern? free your stuff π
)
π§ a little gift for u
There's a command line tool, memstat(1), provided so that you do not have to write an application to do all this. iconic of them honestly.
π« RETURN π«
Varies β go look at the particular functions, bestie, they each do their own thing.
Any method returning a memcached_stat_st expects you to free the memory allocated for it. Yes, again. Free it. π«Ά
π HOME π
Want more info? Go check:
<https://launchpad.net/libmemcached>
π AUTHOR π
Brian Aker, <brian@tangent.org>
π₯ SEE ALSO π₯
and that's the whole vibe π this lil masterpiece is perl v5.42.3, dated 2026-08-19 β slay, go free your structs, ily byeee πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libmemcached-libmemcached-perl 1.001801+dfsg-6build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms