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

Source for file storage_memcache.php

Documentation is available at storage_memcache.php

  1. <?php
  2. /**
  3.  * File containing the ezcCacheStorageMemcacheOptions 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 defining a connection to a Memcache server.
  30.  *
  31.  * @property string $host 
  32.  *            The name of the Memcache host to use, usually localhost.
  33.  * @property int $port 
  34.  *            The port on which to connect to host, usually 11211.
  35.  * @property bool $persistent 
  36.  *            If a persistent connection to the Memcache host is needed. Default
  37.  *            is false. A persistent connection stays open between requests.
  38.  * @property bool $compressed 
  39.  *            If on-the-fly compression is needed. Default is false. Requires the
  40.  *            zlib PHP extension.
  41.  * @property string $lockKey 
  42.  *            Cache key to use for locking. Default is '.ezcLock'.
  43.  * @property int $lockWaitTime 
  44.  *            Time to wait between lock availability checks. Measured in
  45.  *            microseconds ({@link usleep()}). Default is 200000.
  46.  * @property int $maxLockTime 
  47.  *            Time before a lock is considered dead, measured in seconds.
  48.  *            Default is 5.
  49.  * @property string $metaDataKey 
  50.  *            The name of the file used to store meta data. Default is
  51.  *            '.ezcMetaData'.
  52.  *
  53.  * @package Cache
  54.  * @version //autogentag//
  55.  */
  56. {
  57.     /**
  58.      * Parent storage options.
  59.      * 
  60.      * @var ezcCacheStorageOptions 
  61.      */
  62.     protected $storageOptions;
  63.  
  64.     /**
  65.      * Constructs an object with the specified values.
  66.      *
  67.      * @throws ezcBasePropertyNotFoundException
  68.      *          If $options contains a property not defined.
  69.      * @throws ezcBaseValueException
  70.      *          If $options contains a property with a value not allowed.
  71.      * @param array(string=>mixed) $options 
  72.      */
  73.     public function __constructarray $options array() )
  74.     {
  75.         $this->properties['host']         'localhost';
  76.         $this->properties['port']         11211;
  77.         $this->properties['persistent']   false;
  78.         $this->properties['compressed']   false;
  79.         $this->properties['lockWaitTime'200000;
  80.         $this->properties['maxLockTime']  5;
  81.         $this->properties['lockKey']      '.ezcLock';
  82.         $this->properties['metaDataKey']  '.ezcMetaData';
  83.         $this->storageOptions = new ezcCacheStorageOptions();
  84.  
  85.         parent::__construct$options );
  86.     }
  87.  
  88.     /**
  89.      * Sets the option $name to $value.
  90.      *
  91.      * @throws ezcBasePropertyNotFoundException
  92.      *          If the property $name is not defined.
  93.      * @throws ezcBaseValueException
  94.      *          If $value is not correct for the property $name.
  95.      * @param string $name 
  96.      * @param mixed $value 
  97.      * @ignore
  98.      */
  99.     public function __set$name$value )
  100.     {
  101.         switch $name )
  102.         {
  103.             case 'host':
  104.                 if !is_string$value || strlen$value )
  105.                 {
  106.                     throw new ezcBaseValueException$name$value'string, length > 0' );
  107.                 }
  108.                 break;
  109.             case 'port':
  110.                 if !is_int$value || $value )
  111.                 {
  112.                     throw new ezcBaseValueException$name$value'int > 0' );
  113.                 }
  114.                 break;
  115.             case 'persistent':
  116.             case 'compressed':
  117.                 if !is_bool$value ) )
  118.                 {
  119.                     throw new ezcBaseValueException$name$value'bool' );
  120.                 }
  121.                 break;
  122.             case 'lockWaitTime':
  123.             case 'maxLockTime':
  124.                 if !is_int$value || $value )
  125.                 {
  126.                     throw new ezcBaseValueException$name$value'int > 0' );
  127.                 }
  128.                 break;
  129.             case 'lockKey':
  130.             case 'metaDataKey':
  131.                 if !is_string$value || strlen$value )
  132.                 {
  133.                     throw new ezcBaseValueException$name$value'string, length > 0' );
  134.                 }
  135.                 break;
  136.             default:
  137.                 // Delegate
  138.                 $this->storageOptions->$name $value;
  139.         }
  140.         $this->properties[$name$value;
  141.     }
  142.  
  143.     /**
  144.      * Returns the value of the option $name.
  145.      * 
  146.      * @throws ezcBasePropertyNotFoundException
  147.      *          If the property $name is not defined.
  148.      * @param string $name The name of the option to get.
  149.      * @return mixed The option value.
  150.      * @ignore
  151.      */
  152.     public function __get$name )
  153.     {
  154.         if isset$this->properties[$name) )
  155.         {
  156.             return $this->properties[$name];
  157.         }
  158.  
  159.         // Delegate
  160.         return $this->storageOptions->$name;
  161.     }
  162.  
  163.     /**
  164.      * Returns if option $name is defined.
  165.      * 
  166.      * @param string $name Option name to check for
  167.      * @return bool 
  168.      * @ignore
  169.      */
  170.     public function __isset$name )
  171.     {
  172.         return isset$this->properties[$name|| isset$this->storageOptions->$name ) );
  173.     }
  174.  
  175.     /**
  176.      * Merge an ezcCacheStorageOptions object into this object.
  177.      * 
  178.      * @param ezcCacheStorageOptions $options The options to merge.
  179.      * @return void 
  180.      * @ignore
  181.      */
  182.     public function mergeStorageOptionsezcCacheStorageOptions $options )
  183.     {
  184.         $this->storageOptions = $options;
  185.     }
  186. }
  187. ?>
Documentation generated by phpDocumentor 1.4.3