/** * Property write access. * * @param string $propertyName Name of the property. * @param mixed $propertyValue The value for the property. * * @throws ezcBaseValueException * If the value for the property options is not an instance of * ezcCacheStackOptions. * @ignore */ public function __set($propertyName, $propertyValue) { switch ($propertyName) { case 'options': if (!$propertyValue instanceof ezcCacheStackOptions) { throw new ezcBaseValueException($propertyName, $propertyValue, 'ezcCacheStackOptions'); } break; default: parent::__set($propertyName, $propertyValue); return; } $this->properties[$propertyName] = $propertyValue; }
/** * Creates a new cache storage in the given location. * * Options can contain the 'ttl' (Time-To-Live). Specific implementations * can have additional options. * * @throws ezcBasePropertyNotFoundException * If you tried to set a non-existent option value. The accepted * options depend on the ezcCacheStorage implementation and may * vary. * * @param string $location Path to the cache location. Null for * memory-based storage and an existing * writeable path for file or memory/file * storage. * @param array(string=>string) $options Options for the cache */ public function __construct($location, array $options = array()) { parent::__construct($location, array()); }
/** * Creates a new cache storage in the given location. * Creates a new cache storage for a given location. The location in case * of this storage class is a valid file system directory. * * Options can contain the 'ttl' ( Time-To-Life ). This is per default set * to 1 day. The option 'permissions' can be used to define the file * permissions of created cache items. Specific ezcCacheStorageFile * implementations can have additional options. * * For details about the options see {@link ezcCacheStorageFileOptions}. * * @param string $location Path to the cache location * @param array(string=>string) $options Options for the cache. * * @throws ezcBaseFileNotFoundException * If the storage location does not exist. This should usually not * happen, since {@link ezcCacheManager::createCache()} already * performs sanity checks for the cache location. In case this * exception is thrown, your cache location has been corrupted * after the cache was configured. * @throws ezcBaseFileNotFoundException * If the storage location is not a directory. This should usually * not happen, since {@link ezcCacheManager::createCache()} already * performs sanity checks for the cache location. In case this * exception is thrown, your cache location has been corrupted * after the cache was configured. * @throws ezcBaseFilePermissionException * If the storage location is not writeable. This should usually not * happen, since {@link ezcCacheManager::createCache()} already * performs sanity checks for the cache location. In case this * exception is thrown, your cache location has been corrupted * after the cache was configured. * @throws ezcBasePropertyNotFoundException * If you tried to set a non-existent option value. The accepted * options depend on the ezcCacheStorage implementation and may * vary. */ public function __construct($location, $options = array()) { // Sanity check location if (!file_exists($location) || !is_dir($location)) { throw new ezcBaseFileNotFoundException($location, 'cache location', 'Does not exist or is no directory.'); } if (!is_readable($location)) { throw new ezcBaseFilePermissionException($location, ezcBaseFileException::READ, 'Cache location is not readable.'); } if (!is_writeable($location)) { throw new ezcBaseFilePermissionException($location, ezcBaseFileException::WRITE, 'Cache location is not writeable.'); } parent::__construct($location); // Overwrite parent set options with new ezcCacheFileStorageOptions $this->properties['options'] = new ezcCacheStorageFileOptions($options); }