1

memcacheのセッションを正常に構成し、正常にmagento動作しています。ここで、memcache オブジェクトを使用して、magento 自体から memcache セッションをフラッシュしたいと考えています。私が試してみました

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

しかし、上からは何もうまくいきません。

コマンドラインからすべてのセッションをフラッシュできますが、スクリプトからはできません。ここでubuntuはOSとして使用しています。

どんな助けでも大歓迎です。

4

1 に答える 1

1

Try to use:

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

It cleans cache storage, including memcached data. I'm using memcache and here is my shell script to clean cache data:

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();
}

It's cleaning memcache storage. Memcache by default use one storage for cache and sessions. If you want remove all data from current memcached session use class (or or some child) Mage_Core_Model_Session_Abstract_Varien. There is a method unsetAll which removes all data from the session. The method also cleans memcached session if any.

于 2012-12-20T09:28:02.550 に答える