/** * {@inheritdoc} * * @throws ehough_stash_exception_RuntimeException */ public function setOptions(array $options = array()) { $options += $this->getDefaultOptions(); $this->cachePath = rtrim($options['path'], '\\/') . DIRECTORY_SEPARATOR; $this->filePermissions = $options['filePermissions']; $this->dirPermissions = $options['dirPermissions']; $this->busyTimeout = $options['busyTimeout']; $this->nesting = max((int) $options['nesting'], 0); ehough_stash_Utilities::checkFileSystemPermissions($this->cachePath, $this->dirPermissions); $extension = isset($options['extension']) ? strtolower($options['extension']) : 'any'; $version = isset($options['version']) ? $options['version'] : 'any'; $subdrivers = array(); if (ehough_stash_driver_sub_SqlitePdo::isAvailable()) { $subdrivers['pdo'] = 'ehough_stash_driver_sub_SqlitePdo'; } if (ehough_stash_driver_sub_Sqlite::isAvailable()) { $subdrivers['sqlite'] = 'ehough_stash_driver_sub_Sqlite'; } if (ehough_stash_driver_sub_SqlitePdo2::isAvailable()) { $subdrivers['pdo2'] = 'ehough_stash_driver_sub_SqlitePdo2'; } if ($extension == 'pdo' && $version != '2' && isset($subdrivers['pdo'])) { $driver = $subdrivers['pdo']; } elseif ($extension == 'sqlite' && isset($subdrivers['sqlite'])) { $driver = $subdrivers['sqlite']; } elseif ($extension == 'pdo' && $version != '3' && isset($subdrivers['pdo2'])) { $driver = $subdrivers['pdo2']; } elseif (count($subdrivers) > 0 && $extension == 'any') { $driver = reset($subdrivers); } else { throw new ehough_stash_exception_RuntimeException('No sqlite extension available.'); } $this->driverClass = $driver; $this->checkStatus(); }
/** * Requests a list of options. * * @param array $options * * @throws ehough_stash_exception_RuntimeException */ public function setOptions(array $options = array()) { $options += $this->getDefaultOptions(); $this->cachePath = rtrim($options['path'], '\\/') . DIRECTORY_SEPARATOR; $this->filePermissions = $options['filePermissions']; $this->dirPermissions = $options['dirPermissions']; $this->directorySplit = max((int) $options['dirSplit'], 1); $this->memStoreLimit = max((int) $options['memKeyLimit'], 0); if (is_callable($options['keyHashFunction'])) { $this->keyHashFunction = $options['keyHashFunction']; } else { throw new ehough_stash_exception_RuntimeException('Key Hash Function is not callable'); } if (isset($options['encoder'])) { $encoder = $options['encoder']; if (is_object($encoder)) { if (!$encoder instanceof ehough_stash_driver_filesystem_EncoderInterface) { throw new RuntimeException('Encoder object must implement ehough_stash_driver_filesystem_EncoderInterface'); } $this->encoder = new $encoder(); } else { $encoderClass = 'ehough_stash_driver_filesystem_' . $encoder . 'Encoder'; if (class_exists($encoder)) { $this->encoder = new $encoder(); } elseif (class_exists($encoderClass)) { $this->encoder = new $encoderClass(); } else { throw new RuntimeException('Invalid Encoder: ' . $encoder); } } } ehough_stash_Utilities::checkFileSystemPermissions($this->cachePath, $this->dirPermissions); }