PHPExcel
[ class tree: PHPExcel ] [ index: PHPExcel ] [ all elements ]

Source for file CachedObjectStorageFactory.php

Documentation is available at CachedObjectStorageFactory.php

  1. <?php
  2.  
  3.     const cache_in_memory                'Memory';
  4.     const cache_in_memory_gzip            'MemoryGZip';
  5.     const cache_in_memory_serialized    'MemorySerialized';
  6.     const cache_to_discISAM                'DiscISAM';
  7.     const cache_to_apc                    'APC';
  8.     const cache_to_memcache                'Memcache';
  9.     const cache_to_phpTemp                'PHPTemp';
  10.     const cache_to_wincache                'Wincache';
  11.  
  12.  
  13.     private static $_cacheStorageMethod null;
  14.  
  15.     private static $_cacheStorageClass null;
  16.  
  17.  
  18.     private static $_storageMethods array(
  19.         self::cache_in_memory,
  20.         self::cache_in_memory_gzip,
  21.         self::cache_in_memory_serialized,
  22.         self::cache_to_phpTemp,
  23.         self::cache_to_discISAM,
  24.         self::cache_to_apc,
  25.         self::cache_to_memcache,
  26.         self::cache_to_wincache,
  27.     );
  28.  
  29.  
  30.     private static $_storageMethodDefaultParameters array(
  31.         self::cache_in_memory                => array(
  32.                                                     ),
  33.         self::cache_in_memory_gzip            => array(
  34.                                                     ),
  35.         self::cache_in_memory_serialized    => array(
  36.                                                     ),
  37.         self::cache_to_phpTemp                => array'memoryCacheSize'    => '1MB'
  38.                                                     ),
  39.         self::cache_to_discISAM                => array(
  40.                                                     ),
  41.         self::cache_to_apc                    => array'cacheTime'        => 600
  42.                                                     ),
  43.         self::cache_to_memcache                => array'memcacheServer'    => 'localhost',
  44.                                                       'memcachePort'    => 11211,
  45.                                                       'cacheTime'        => 600
  46.                                                     ),
  47.         self::cache_to_wincache                => array'cacheTime'        => 600
  48.                                                     )
  49.     );
  50.  
  51.  
  52.     private static $_storageMethodParameters array();
  53.  
  54.  
  55.     public static function getCacheStorageMethod({
  56.         if (!is_null(self::$_cacheStorageMethod)) {
  57.             return self::$_cacheStorageMethod;
  58.         }
  59.         return null;
  60.     }    //    function getCacheStorageMethod()
  61.  
  62.  
  63.     public static function getCacheStorageClass({
  64.         if (!is_null(self::$_cacheStorageClass)) {
  65.             return self::$_cacheStorageClass;
  66.         }
  67.         return null;
  68.     }    //    function getCacheStorageClass()
  69.  
  70.  
  71.     public static function getCacheStorageMethods({
  72.         return self::$_storageMethods;
  73.     }    //    function getCacheStorageMethods()
  74.  
  75.  
  76.     public static function initialize($method self::cache_in_memory$arguments array()) {
  77.         if (!in_array($method,self::$_storageMethods)) {
  78.             return false;
  79.         }
  80.  
  81.         switch($method{
  82.             case self::cache_to_apc    :
  83.                 if (!function_exists('apc_store')) {
  84.                     return false;
  85.                 }
  86.                 if (apc_sma_info(=== false{
  87.                     return false;
  88.                 }
  89.                 break;
  90.             case self::cache_to_memcache :
  91.                 if (!function_exists('memcache_add')) {
  92.                     return false;
  93.                 }
  94.                 break;
  95.             case self::cache_to_wincache :
  96.                 if (!function_exists('wincache_ucache_add')) {
  97.                     return false;
  98.                 }
  99.                 break;
  100.         }
  101.  
  102.         self::$_storageMethodParameters[$methodself::$_storageMethodDefaultParameters[$method];
  103.         foreach($arguments as $k => $v{
  104.             if (isset(self::$_storageMethodParameters[$method][$k])) {
  105.                 self::$_storageMethodParameters[$method][$k$v;
  106.             }
  107.         }
  108.  
  109.         if (is_null(self::$_cacheStorageMethod)) {
  110.             self::$_cacheStorageClass 'PHPExcel_CachedObjectStorage_'.$method;
  111.             self::$_cacheStorageMethod $method;
  112.         }
  113.         return true;
  114.     }    //    function initialize()
  115.  
  116.  
  117.     public static function getInstance(PHPExcel_Worksheet $parent{
  118.         if (is_null(self::$_cacheStorageMethod)) {
  119.             self::initialize();
  120.         }
  121.  
  122.         $instance new self::$_cacheStorageClass($parent,self::$_storageMethodParameters[self::$_cacheStorageMethod]);
  123.         if (!is_null($instance)) {
  124.             return $instance;
  125.         }
  126.  
  127.         return false;
  128.     }    //    function getInstance()
  129.  
  130. }

Documentation generated on Sun, 27 Feb 2011 16:28:41 -0800 by phpDocumentor 1.4.3