You are here

function _phpexcel_get_cache_settings in PHPExcel 8.3

Same name and namespace in other branches
  1. 7.3 phpexcel.inc \_phpexcel_get_cache_settings()

Determine the cache settings.

Based on the site configuration, return the correct cache settings and method to be used by PHPExcel.

Return value

array The first key is the caching method, the second the settings.

2 calls to _phpexcel_get_cache_settings()
phpexcel_export in ./phpexcel.inc
Simple API function which will generate an XLS file and save it in $path.
phpexcel_import in ./phpexcel.inc
Import an Excel file.

File

./phpexcel.inc, line 574
Defines the phpexcel api functions that other modules can use.

Code

function _phpexcel_get_cache_settings() {
  $cache_settings = array();
  $phpexcel_config = \Drupal::config('phpexcel.settings');
  switch ($phpexcel_config
    ->get('cache_mechanism')) {
    case 'cache_in_memory_serialized':
      $cache_method = PHPExcel_CachedObjectStorageFactory::cache_in_memory_serialized;
      break;
    case 'cache_in_memory_gzip':
      $cache_method = PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip;
      break;
    case 'cache_to_phpTemp':
      $cache_method = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
      $cache_settings = array(
        'memoryCacheSize' => $phpexcel_config
          ->get('phptemp_limit') . 'MB',
      );
      break;
    case 'cache_to_apc':
      $cache_method = PHPExcel_CachedObjectStorageFactory::cache_to_apc;
      $cache_settings = array(
        'cacheTime' => $phpexcel_config
          ->get('apc_cachetime'),
      );
      break;
    case 'cache_to_memcache':
      $cache_method = PHPExcel_CachedObjectStorageFactory::cache_to_memcache;
      $cache_settings = array(
        'memcacheServer' => $phpexcel_config
          ->get('memcache_host'),
        'memcachePort' => $phpexcel_config
          ->get('_memcache_port'),
        'cacheTime' => $phpexcel_config
          ->get('memcache_cachetime'),
      );
      break;
    case 'cache_to_sqlite3':
      $cache_method = PHPExcel_CachedObjectStorageFactory::cache_to_sqlite3;
      break;
    default:
      $cache_method = PHPExcel_CachedObjectStorageFactory::cache_in_memory;
      break;
  }
  return array(
    $cache_method,
    $cache_settings,
  );
}