Warning: Memcache::get() [memcache.get]: Node no longer exists
I am new to memcached but I do need to fix this error quick on the website
I don't know where to cut in?
Anything that I can do to find out which node or key memcac开发者_运维问答hed failed to get?
Any log files can I look into?
This occurs when you store an object which has references to recources such as file descriptors or database connections. It can also occur if the object you get is of a class which isn't loaded when you get it from memcached.
To find out which memcached key fails, you could set a custom error handler, which can access the memcached key, just before the call to Memcached::get and restore it afterwards. Then you can log the warning together with the key.
[Edit] Here's an example:
<?
class MyMemcachedWrapper {
private $key;
public function get($key) {
// Save the key in an instance variable so it will be available in
// the error handler
$this->key = $key;
set_error_handler(array($this, 'handleError'));
$value = Memcached::get($key);
restore_error_handler();
return $value;
}
public function handleError($errno, $errstr) {
// Here we have both the key and the error message from memcached
$message = "Memcached error '$errstr' while fetching key '{this->key}'";
// ... and we can log it to a file or db or something
file_put_contents("memcached-errors.log", $message, FILE_APPEND);
}
}
// Then use it like this
$memcached_wrapper = new MyMemcachedWrapper();
$value = $memcached_wrapper->get('xyz');
精彩评论