public function testGetBaseDirectory() { $filesystem = new ehough_stash_driver_FileSystem(); $tmp = sys_get_temp_dir(); $directory = ehough_stash_Utilities::getBaseDirectory($filesystem); $this->assertStringStartsWith($tmp, $directory, 'Base directory is placed inside the system temp directory.'); $this->assertTrue(is_dir($directory), 'Base Directory exists and is a directory'); $this->assertTrue(touch($directory . 'test'), 'Base Directory is writeable.'); }
public function __construct(array $options = array()) { $options = array_merge($this->defaultOptions, $options); $this->cachePath = isset($options['path']) ? $options['path'] : ehough_stash_Utilities::getBaseDirectory($this); $this->cachePath = rtrim($this->cachePath, '\\/') . DIRECTORY_SEPARATOR; $this->filePermissions = $options['filePermissions']; $this->dirPermissions = $options['dirPermissions']; if (!is_numeric($options['dirSplit']) || $options['dirSplit'] < 1) { $options['dirSplit'] = 1; } $this->directorySplit = (int) $options['dirSplit']; if (!is_numeric($options['memKeyLimit']) || $options['memKeyLimit'] < 1) { $options['memKeyLimit'] = 0; } if (function_exists($options['keyHashFunction'])) { $this->keyHashFunction = $options['keyHashFunction']; } else { throw new ehough_stash_exception_RuntimeException('Key Hash Function does not exist'); } $this->memStoreLimit = (int) $options['memKeyLimit']; $this->checkFileSystemPermissions(); }
/** * * @param array $options */ public function __construct(array $options = array()) { $options = array_merge($this->defaultOptions, $options); $cachePath = isset($options['path']) ? $options['path'] : ehough_stash_Utilities::getBaseDirectory($this); $this->cachePath = rtrim($cachePath, '\\/') . '/'; $this->checkFileSystemPermissions(); $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->filePerms = $options['filePermissions']; $this->dirPerms = $options['dirPermissions']; $this->busyTimeout = $options['busyTimeout']; $this->nesting = $options['nesting']; $this->checkStatus(); }
public static function tearDownAfterClass() { ehough_stash_Utilities::deleteRecursive(ehough_stash_Utilities::getBaseDirectory()); }
/** * {@inheritdoc} */ public function getDefaultOptions() { return array('path' => ehough_stash_Utilities::getBaseDirectory($this), 'filePermissions' => 0660, 'dirPermissions' => 0770, 'busyTimeout' => 500, 'nesting' => 0, 'subdriver' => 'PDO'); }
/** * {@inheritdoc} */ public function getDefaultOptions() { return array('path' => ehough_stash_Utilities::getBaseDirectory($this), 'filePermissions' => 0660, 'dirPermissions' => 0770, 'dirSplit' => 2, 'memKeyLimit' => 20, 'keyHashFunction' => 'md5'); }