Cache Statistics
darkalchemy opened this issue · 2 comments
darkalchemy commented
Would it be possible to add a method to provide cache stats such as hits, misses and memory used?
matthiasmullie commented
Hey @darkalchemy
I won't add such method to the KeyValueStore interface because:
- Not all adapters would have such information (APC, SQL, filesystem, memory)
- The information could only be retrieved for a cache server or pool (and would not be correct for Collections)
However... Scrapbook is "only a layer of standardization" on top of specific cache clients.
While this type of info is hard/impossible to standardize across different adapters, you could fetch these stats from the client directly (if available from the client):
// create \Memcached object pointing to your Memcached server
$client = new \Memcached();
$client->addServer('localhost', 11211);
// create Scrapbook cache object
$cache = new \MatthiasMullie\Scrapbook\Adapters\Memcached($client);
// do operations with Scrapbook
$cache->set('key', 'value');
$cache->get('key');
// get stats directly from Memcached client
var_dump($client->getStats());
darkalchemy commented
I thought that might be the case.
Thank you