77 public function __construct($cache_type, $dbm_filename, $lock_filename) {
80 if (!extension_loaded(
'dba')) {
81 throw new Exception(
'PHP is not compiled with dba support, required to use DBM style cache.');
85 if (!function_exists(
'dba_handlers') || !in_array($cache_type, dba_handlers())) {
86 throw new Exception(
'PHP is not compiled --with '.$cache_type.
' support, required to use DBM style cache.');
90 if (!file_exists($lock_filename)) {
91 if (!touch($lock_filename)) {
92 throw new Exception(
'failed to create lock file: '.$lock_filename);
97 if (!is_writeable($lock_filename)) {
98 throw new Exception(
'lock file: '.$lock_filename.
' is not writable');
100 $this->lock =
fopen($lock_filename,
'w');
103 flock($this->lock, LOCK_EX);
106 if (!file_exists($dbm_filename)) {
107 if (!touch($dbm_filename)) {
108 throw new Exception(
'failed to create dbm file: '.$dbm_filename);
113 $this->dba = dba_open($dbm_filename,
'w', $cache_type);
117 $this->dba = dba_open($dbm_filename,
'n', $cache_type);
120 throw new Exception(
'failed to create dbm file: '.$dbm_filename);
128 $this->cache_type = $cache_type;
129 $this->dbm_filename = $dbm_filename;
132 register_shutdown_function(array($this,
'__destruct'));
139 parent::__construct();
148 dba_close($this->dba);
151 flock($this->lock, LOCK_UN);
163 dba_close($this->dba);
166 $this->dba = dba_open($this->dbm_filename,
'n', $this->cache_type);
169 throw new Exception(
'failed to clear cache/recreate dbm file: '.$this->dbm_filename);
176 register_shutdown_function(array($this,
'__destruct'));
getID3() by James Heinrich info@getid3.org //
__construct($cache_type, $dbm_filename, $lock_filename)