i trying build configuration parser application installed apc today, everytime try put serialized object in store, not in there , not. (i checking apc.php version[3.1.8-dev] on php 5.3.16 [my dev environment], sure data not in cache). how pass data cacher:
// data before caching array ( 'key' => md5($this->filename), 'value' => serialize($this->cfg) ); // caching interface function($argc){ $key = $argc['key']; cache\apc::getinstance()->set($key,$argc['value']); } // caching method described above public function set($key, $val) { if (apc_exists($key)) { apc_delete ($key); return apc_store($key, $val); } else return false; } // constructor of configuration class. // 1st looks configuration in // cache if not present performs reading 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"; } } }
i did few tests , there not problem md5() key (which thought while writing question) nor apc itself. stuck on one, nothing odd in logs, if can give me @ least directions appreciated.
thanks in advance!
the problem in code:\
public function set($key, $val) { /* * * if key exists in cache delete , store again, * how exist when else clause that... */ if (apc_exists($key)) { apc_delete ($key); return apc_store($key, $val); } // wrong in current case // cuz function never store , if // never match.. else return false; }
note: think , keep eyes open, if still can't find off pc , give rest. after 10-15 minutes , pown code. helps! :d
Comments
Post a Comment