警告:Memcache :: get()[memcache.get]:节点不再存在 [英] Warning: Memcache::get() [memcache.get]: Node no longer exists
问题描述
我是memcached的新手,但我确实需要在网站上快速修复此错误
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?
我能做些什么来找出哪个节点或键的memcached失败了?
Anything that I can do to find out which node or key memcached failed to get?
我可以查看任何日志文件吗?
Any log files can I look into?
推荐答案
当您存储的对象具有对资源的引用(例如文件描述符或数据库连接)时,会发生这种情况.如果您获得的对象属于从memcached获取对象时未加载的类,则也会发生这种情况.
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.
要找出哪个memcached密钥失败,可以在调用Memcached :: get之前设置一个自定义错误处理程序,该错误处理程序可以访问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.
这是一个示例:
<?
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');
这篇关于警告:Memcache :: get()[memcache.get]:节点不再存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!