I started working with memcached short time ago to relive our DB from the
stress it was inn, and i actually feel a difference and think it's a lot
more responsive now.
But i wonder how i actually see the "success rate" of my efforts. I have a
very weird patern, where it cmd_get is equal to cmd_hits and cmd set is
equal to get_misses.
Is it not correct that get_hits + get_misses = cmd_get ?
stats
STAT pid 16758
STAT uptime 508
STAT time 1351363371
STAT version 1.4.2
STAT pointer_size 64
STAT rusage_user 0.070000
STAT rusage_system 0.140000
STAT curr_connections 5
STAT total_connections 1655
STAT connection_structures 9
STAT cmd_get 1312
STAT cmd_set 941
STAT cmd_flush 0
STAT get_hits 1312
STAT get_misses 941
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT bytes_read 1013175
STAT bytes_written 1283468
STAT limit_maxbytes 2147483648
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT bytes 3637
STAT curr_items 5
STAT total_items 935
STAT evictions 0
END
Typical usage is something like below. It's not built into my DB handler
yet because i only need to use it on very few very frequently run queries.
<?php
$mc = MyMemcached::getInstance();
$memcachedKey = "SQL:1:FOO:" . $uniqueFooIdentifier;
$foo = $mc->get($memcachedKey);
if($foo === false) {
DOES SOME SQL STUFF AND FETCH FOO FROM DB
//Save it in memcached
//CFG_CACHE_TIMEOUT_FOO is static set to fx 15secs i also do some micro
caching on some very frequent queries where the time is set to 1/2secs
$mc->set($memcachedKey, $foo, CFG_CACHE_TIMEOUT_FOO);
}
?>
Best regards //Nevz