0

私は次のコードを持っています:

application.ini

cache.default.adapter = "memcached"
cache.default.params.host = "localhost"
cache.default.params.port = "11211"

Bootstrap.php

$cache = new Memcache();        
$cache->connect($cache_params['host'], $cache_params['port']);
Zend_Registry::set("cache", $cache);

また、php.iniに入力php_memcache.dllしてマシンに memcache をインストールしています。wamp\bin\php\php5.3.9\extextension=php_memcache.dll

しかし、それでも次のエラーが発生します。

( ! ) 致命的なエラー: クラス 'Memcache' が \wamp\www\projectname\application\Bootstrap.php の 160 行目に見つかりません

私はグーグルを通過しましたが、まだ問題を解決できません。memcache に接続していない理由は何ですか。

4

2 に答える 2

1

データベースをキャッシュしようとしていますか?

Zend_Cache を使用したい。

(出典: http://zendcoding.com/how-to-use-memcached-in-the-zend-framework )

$frontendOpts = array(
    'caching' => true,
    'lifetime' => 1800, //how long in seconds to keep the cache for.
    'automatic_serialization' => true //In order to store objects and arrays, Zend must first serialize data into a string. If this parameter is set to ‘true‘, this serialization will happen on the fly and behind the scenes.
);

$backendOpts = array(
    'servers' =>array(
        array(
        'host'   => $cache_params['host'],
        'port'   => $cache_params['port'],
        'weight' => 1
        )
    ),
    'compression' => false
);

$cache = Zend_Cache::factory('Core', 'Memcached', $frontendOpts, $backendOpts);

このリンクは、キャッシュをロードおよび更新する方法と、アプリケーションのどこからでもアクセスできるようにする方法も示しています。確かに、よく読んでください。

于 2012-10-17T09:58:00.010 に答える