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

Source for file stack.php

Documentation is available at stack.php

  1. <?php
  2. /**
  3.  * File containing the ezcCacheStackOptions 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.  * Options class for ezcCacheStack instances.
  30.  * 
  31.  * This options class is used with {@link ezcCacheStack} instances.
  32.  *
  33.  * The $configurator property is special, since it only takes effect during
  34.  * construction of the stack. The idea is, to use this in combination with
  35.  * {@link ezcCacheManager}. The method {@link }
  36.  * ezcCacheStackConfigurator::configure()} will called by the constructor of
  37.  * {@link ezcCacheStack}. Inside this method, the configuration of the stack
  38.  * can happen as needed. Therefore, the {@link ezcCacheStackableStorage}
  39.  * instances for the stack do not need to exist when the stack is configured in
  40.  * the {@link ezcCacheManager}.
  41.  *
  42.  * The rest of the options is used as usual to affect the behavior of the
  43.  * {@link ezcCacheStack}. However, it is highly recommended to not change
  44.  * $metaStorage and $replacementStrategy once they have been set for a stack.
  45.  * If these options are changed, the whole stack needs to be resetted using
  46.  * {@link ezcCacheStack::reset()}. Aside of that, the previous $metaStorage
  47.  * needs to be resetted.
  48.  *
  49.  * @property string $configurator 
  50.  *            Name of a class implementing ezcCacheStackConfigurator. This class
  51.  *            will be used right after construction of the stack, to perform
  52.  *            initial configuration. After the construction process, this option
  53.  *            does not have any effect. Null (default) means no configuration.
  54.  * @property ezcCacheStackMetaDataStorage $metaStorage 
  55.  *            This storage will be used to store the meta data of the
  56.  *            replacement strategy used by the stack. If null (default) is
  57.  *            given, the top most storage will be used.
  58.  * @property string $replacementStrategy 
  59.  *            The  name of the class given in this property must extend {@link }
  60.  *            ezcCacheReplacementStrategy}. The class will be used as the
  61.  *            replacement strategy in the stack. ezcCacheLruReplacementStrategy
  62.  *            is the default.
  63.  * @property bool $bubbleUpOnRestore 
  64.  *            This option determines if data that is restored from a storage in
  65.  *            the stack will be bubbled up to higher caches. The default here is
  66.  *            false, since it might significantly reduce the {@link }
  67.  *            ezcCacheStack::restore()} performance. In addition, for bubbled up
  68.  *            items, only the attributes will be used that have been provided
  69.  *            while restoring the desired item. Also the lifetime of the item
  70.  *            will practically be reset, since higher storages will start with a
  71.  *            fresh TTL value.
  72.  * @package Cache
  73.  * @version //autogen//
  74.  */
  75. {
  76.     /**
  77.      * Construct a new options object.
  78.      * Options are constructed from an option array by default. The constructor
  79.      * automatically passes the given options to the __set() method to set them
  80.      * in the class.
  81.      * 
  82.      * @throws ezcBasePropertyNotFoundException
  83.      *          If trying to access a non existent property.
  84.      * @throws ezcBaseValueException
  85.      *          If the value for a property is out of range.
  86.      * @param array(string=>mixed) $options The initial options to set.
  87.      */
  88.     public function __constructarray $options array() )
  89.     {
  90.         $this->properties['configurator']        null;
  91.         $this->properties['metaStorage']         null;
  92.         $this->properties['replacementStrategy''ezcCacheStackLruReplacementStrategy';
  93.         $this->properties['bubbleUpOnRestore']   false;
  94.         parent::__construct$options );
  95.     }
  96.  
  97.     /**
  98.      * Sets an option.
  99.      * This method is called when an option is set.
  100.      * 
  101.      * @param string $propertyName  The name of the option to set.
  102.      * @param mixed $propertyValue The option value.
  103.      * @ignore
  104.      *
  105.      * @throws ezcBasePropertyNotFoundException
  106.      *          if the given property does not exist.
  107.      * @throws ezcBaseValueException
  108.      *          if the value to be assigned to a property is invalid.
  109.      * @throws ezcBasePropertyPermissionException
  110.      *          if the property to be set is a read-only property.
  111.      */
  112.     public function __set$propertyName$propertyValue )
  113.     {
  114.         switch $propertyName )
  115.         {
  116.             case 'configurator':
  117.                 if $propertyValue !== null && !is_string$propertyValue || !class_exists$propertyValue ) )
  118.                      || !in_array'ezcCacheStackConfigurator'class_implements$propertyValue ) ) ) )
  119.                 {
  120.                     throw new ezcBaseValueException(
  121.                         $propertyName,
  122.                         $propertyValue,
  123.                         'existsing class implementing ezcCacheStackConfigurator or null'
  124.                     );
  125.                 }
  126.                 break;
  127.             case 'metaStorage':
  128.                 if $propertyValue !== null && !$propertyValue instanceof ezcCacheStackMetaDataStorage ) )
  129.                 {
  130.                     throw new ezcBaseValueException(
  131.                         $propertyName,
  132.                         $propertyValue,
  133.                         'ezcCacheStackMetaDataStorage or null'
  134.                     );
  135.                 }
  136.                 break;
  137.             case 'replacementStrategy':
  138.                 if !is_string$propertyValue || !class_exists$propertyValue || !in_array'ezcCacheStackReplacementStrategy'class_implements$propertyValue ) ) )
  139.                 {
  140.                     throw new ezcBaseValueException(
  141.                         $propertyName,
  142.                         $propertyValue,
  143.                         'existing class implementing ezcCacheStackReplacementStrategy'
  144.                     );
  145.                 }
  146.                 break;
  147.             case 'bubbleUpOnRestore':
  148.                 if !is_bool$propertyValue ) )
  149.                 {
  150.                     throw new ezcBaseValueException(
  151.                         $propertyName,
  152.                         $propertyValue,
  153.                         'bool'
  154.                     );
  155.                 }
  156.                 break;
  157.             default:
  158.                 throw new ezcBasePropertyNotFoundException$propertyName );
  159.         }
  160.         $this->properties[$propertyName$propertyValue;
  161.     }
  162. }
  163.  
  164. ?>
Documentation generated by phpDocumentor 1.4.3