对于memcache,会话刷新在magento中不起作用

时间:2012-12-20 08:55:33

标签: magento session memcached

我已成功为memcache配置了magento会话,但它运行正常。现在我想通过使用memcache对象从magento本身刷新memcache会话。 我试过了

$memcache = new Memcache();
$memcache->flush();
$memcache->flush_all();
$memcache->delete(arguments);

但从上面来看,没有什么对我有用。

我能够从命令行刷新所有会话,但不能从脚本中执行。我在这里使用ubuntu作为操作系统。

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

尝试使用:

Mage::app()->getCacheInstance()->flush();

它清除缓存存储,包括memcached数据。我正在使用memcache,这是我的shell脚本来清​​理缓存数据:

ini_set("display_errors", 1);

require '../app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);
Mage::getConfig()->init();

try {
    Mage::app()->cleanCache(); // Clean Magento caches
    Mage::app()->getCacheInstance()->flush(); // Clean cache storage

    echo "\033[01;31m Cache instances were flushed successfully \033[0m \n";
    flush();
} catch (Exception $e) {
    echo "\nAn error was occurred: " . $e->getMessage() . "\n";
    flush();
}

它正在清理内存缓存。默认情况下,Memcache使用一个存储空间来缓存和会话。如果要从当前memcached会话中删除所有数据,请使用类(或部分子级)Mage_Core_Model_Session_Abstract_Varien。有一个方法unsetAll可以从会话中删除所有数据。该方法还清除memcached会话(如果有的话)。

相关问题