Apache Zeta Components Manual :: File Source for storage_file.php

Source for file storage_file.php

Documentation is available at storage_file.php

  1. <?php
  2. /**
  3.  * File containing the ezcCacheStorageFileOptions class.
  4.  *
  5.  * Licensed to the Apache Software Foundation (ASF) under one
  6.  * or more contributor license agreements.  See the NOTICE file
  7.  * distributed with this work for additional information
  8.  * regarding copyright ownership.  The ASF licenses this file
  9.  * to you under the Apache License, Version 2.0 (the
  10.  * "License"); you may not use this file except in compliance
  11.  * with the License.  You may obtain a copy of the License at
  12.  * 
  13.  *   http://www.apache.org/licenses/LICENSE-2.0
  14.  * 
  15.  * Unless required by applicable law or agreed to in writing,
  16.  * software distributed under the License is distributed on an
  17.  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18.  * KIND, either express or implied.  See the License for the
  19.  * specific language governing permissions and limitations
  20.  * under the License.
  21.  *
  22.  * @package Cache
  23.  * @version //autogentag//
  24.  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  25.  * @filesource
  26.  */
  27.  
  28. /**
  29.  * Option class for the ezcCacheStorageFile class.
  30.  * Instances of this class store the option of ezcCacheStorageFile implementations.
  31.  *
  32.  * @property int $ttl 
  33.  *            The time to live of cache entries.
  34.  * @property string $extension 
  35.  *            The (file) extension to use for the storage items.
  36.  * @property int $permissions 
  37.  *            Permissions to create a file with (Posix only).
  38.  * @property string $lockFile 
  39.  *            The name of the file used for locking in the lock() method.
  40.  *            Default is '.ezcLock'.
  41.  * @property int $lockWaitTime 
  42.  *            Time to wait between lock availability checks. Measured in
  43.  *            microseconds ({@link usleep()}). Default is 200000.
  44.  * @property int $maxLockTime 
  45.  *            Time before a lock is considered dead, measured in seconds.
  46.  *            Default is 5.
  47.  * @property string $metaDataFile 
  48.  *            The name of the file used to store meta data. Default is
  49.  *            '.ezcMetaData'.
  50.  *
  51.  * @package Cache
  52.  * @version //autogentag//
  53.  */
  54. {
  55.     /**
  56.      * Parent storage options.
  57.      * 
  58.      * @var ezcCacheStorageOptions 
  59.      */
  60.     protected $storageOptions;
  61.  
  62.     /**
  63.      * Constructs a new options class.
  64.      *
  65.      * It also sets the default values of the format property
  66.      *
  67.      * @param array(string=>mixed) $options The initial options to set.
  68.      
  69.      * @throws ezcBasePropertyNotFoundException
  70.      *          If trying to assign a property which does not exist
  71.      * @throws ezcBaseValueException
  72.      *          If the value for the property is incorrect
  73.      */
  74.     public function __construct$options array() )
  75.     {
  76.         $this->properties['permissions']  0644;
  77.         $this->properties['lockFile']     '.ezcLock';
  78.         $this->properties['lockWaitTime'200000;
  79.         $this->properties['maxLockTime']  5;
  80.         $this->properties['lockFile']     '.ezcLock';
  81.         $this->properties['metaDataFile''.ezcMetaData';
  82.         $this->storageOptions = new ezcCacheStorageOptions();
  83.         parent::__construct$options );
  84.     }
  85.  
  86.     /**
  87.      * Sets an option.
  88.      * This method is called when an option is set.
  89.      * 
  90.      * @param string $key  The option name.
  91.      * @param mixed $value The option value.
  92.      * @ignore
  93.      */
  94.     public function __set$key$value )
  95.     {
  96.         switch $key )
  97.         {
  98.             case "permissions":
  99.                 if !is_int$value )  || $value || $value 0777 )
  100.                 {
  101.                     throw new ezcBaseValueException$key$value"int > 0 and <= 0777" );
  102.                 }
  103.                 break;
  104.             case "lockFile":
  105.                 if !is_string$value )  || strlen$value || strlen$value 250 )
  106.                 {
  107.                     throw new ezcBaseValueException(
  108.                         $key,
  109.                         $value,
  110.                         'string, length > 0 and < 250'
  111.                     );
  112.                 }
  113.                 break;
  114.             case "lockWaitTime":
  115.                 if !is_int$value )  || $value )
  116.                 {
  117.                     throw new ezcBaseValueException(
  118.                         $key,
  119.                         $value,
  120.                         'int > 0'
  121.                     );
  122.                 }
  123.                 break;
  124.             case "maxLockTime":
  125.                 if !is_int$value )  || $value )
  126.                 {
  127.                     throw new ezcBaseValueException(
  128.                         $key,
  129.                         $value,
  130.                         'int > 0'
  131.                     );
  132.                 }
  133.                 break;
  134.             case "metaDataFile":
  135.                 if !is_string$value )  || strlen$value || strlen$value 250 )
  136.                 {
  137.                     throw new ezcBaseValueException(
  138.                         $key,
  139.                         $value,
  140.                         'string, length > 0 and < 250'
  141.                     );
  142.                 }
  143.                 break;
  144.             // Delegate
  145.             default:
  146.                 $this->storageOptions->$key $value;
  147.                 return;
  148.         }
  149.         $this->properties[$key$value;
  150.     }
  151.  
  152.     /**
  153.      * Property get access.
  154.      * Simply returns a given option.
  155.      * 
  156.      * @throws ezcBasePropertyNotFoundException
  157.      *          If trying to assign a property which does not exist
  158.      * @param string $key The name of the option to get.
  159.      * @return mixed The option value.
  160.      * @ignore
  161.      */
  162.     public function __get$key )
  163.     {
  164.         if isset$this->properties[$key) )
  165.         {
  166.             return $this->properties[$key];
  167.         }
  168.         // Delegate
  169.         return $this->storageOptions->$key;
  170.     }
  171.  
  172.     /**
  173.      * Returns if a option exists.
  174.      * 
  175.      * @param string $key Option name to check for.
  176.      * @return void 
  177.      * @ignore
  178.      */
  179.     public function __isset$key )
  180.     {
  181.         // Delegate
  182.         return array_key_exists$key$this->properties || isset$this->storageOptions->$key ) );
  183.     }
  184.  
  185.     /**
  186.      * Merge an ezcCacheStorageOptions object into this object.
  187.      * 
  188.      * @param ezcCacheStorageOptions $options The options to merge.
  189.      * @return void 
  190.      * @ignore
  191.      */
  192.     public function mergeStorageOptionsezcCacheStorageOptions $options )
  193.     {
  194.         $this->storageOptions = $options;
  195.     }
  196. }
  197.  
  198. ?>
Documentation generated by phpDocumentor 1.4.3