今日 APC をインストールしたアプリケーションの構成パーサーを構築しようとしていますが、シリアル化されたオブジェクトをストアに入れようとするたびに、ストアに入れられません。(PHP 5.3.16 [私の開発環境] で私のバージョン [3.1.8-dev] を apc.php でチェックしているので、データがキャッシュにないことは確かです)。これは、データをキャッシャーに渡す方法です。
// The data before the caching
array (
'key' => md5($this->filename),
'value' => serialize($this->cfg)
);
// The caching interface
function($argc){
$key = $argc['key'];
Cache\APC::getInstance()->set($key,$argc['value']);
}
// The caching method described above
public function set($key, $val) {
if (apc_exists($key)) {
apc_delete ($key);
return apc_store($key, $val);
}
else
return false;
}
// the constructor of the configuration class.
// It 1st looks for the configuration in
// the cache if it is not present performs the reading from the file.
public function __construct($filename = '/application/config/application.ini',
$type = self::CONFIG_INI)
{
if (defined('SYSTEM_CACHE') && SYSTEM_CACHE === 'APC'){
$key = md5($filename);
$cfg = APC::getInstance()->get($key);
if (!empty($cfg)) {
print "From Cache";
$this->cfg = unserialize($cfg);
return;
} else {
print "From File";
}
}
}
私はいくつかのテストを行いましたが、MD5() キー (この質問を書いているときに考えた) にも APC 自体にも問題はありません。私は本当にこれに行き詰まっています。ログに奇妙なことはありません。誰かが私に少なくともいくつかの指示を与えることができれば、非常に感謝しています.
前もって感謝します!