当前位置: 首页>>代码示例>>PHP>>正文


PHP StorageFactory::factory方法代码示例

本文整理汇总了PHP中Zend\Cache\StorageFactory::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP StorageFactory::factory方法的具体用法?PHP StorageFactory::factory怎么用?PHP StorageFactory::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Cache\StorageFactory的用法示例。


在下文中一共展示了StorageFactory::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createService

 /**
  * {@inheritDoc}
  *
  * @return ApiService
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Config');
     $columnisConfig = isset($config['columnis']) ? $config['columnis'] : array();
     $apiConfig = isset($columnisConfig['api_settings']) ? $columnisConfig['api_settings'] : array();
     if (!isset($apiConfig['client_number'])) {
         throw new ClientNumberNotSetException("There is no client_number set in local.php config file.");
     }
     if (!isset($apiConfig['api_base_url'])) {
         throw new ApiBaseUrlNotSetException("There is no api_base_url set in local.php config file.");
     }
     $clientNumber = $apiConfig['client_number'];
     $apiUrl = $apiConfig['api_base_url'];
     $httpClient = new GuzzleClient(array('base_url' => $apiUrl));
     $cacheConfig = isset($config['guzzle_cache']) ? $config['guzzle_cache'] : array();
     if (isset($cacheConfig['adapter'])) {
         $cache = StorageFactory::factory($cacheConfig);
         $zfCacheAdapter = new ZfCacheAdapter($cache);
         $cacheSubscriber = new CacheSubscriber($zfCacheAdapter, function (RequestInterface $request) use($zfCacheAdapter) {
             return !$zfCacheAdapter->contains($request);
         });
         $httpClient->getEmitter()->attach($cacheSubscriber);
     }
     return new ApiService($httpClient, $clientNumber);
 }
开发者ID:solcre,项目名称:columnis-express,代码行数:30,代码来源:ApiServiceFactory.php

示例2: getServiceConfig

 public function getServiceConfig()
 {
     return array('factories' => array('MajesticExternalForms\\Models\\MajesticExternalFormsModel' => function ($sm) {
         $model_forms = new MajesticExternalFormsModel();
         return $model_forms;
     }, 'MajesticExternalForms\\Events\\MajesticExternalFormsEvents' => function ($sm) {
         $events_external_forms = new MajesticExternalFormsEvents();
         return $events_external_forms;
     }, 'MajesticExternalForms\\Models\\MajesticExternalFormsCacheModel' => function ($sm) {
         $arr_config = $sm->get("config");
         try {
             $cache = StorageFactory::factory($arr_config["cache_redis_config_common"]);
         } catch (\Exception $e) {
             $dir = "./data/cache/external_forms";
             if (!is_dir("./data/cache/external_forms")) {
                 mkdir($dir, 0777, TRUE);
             }
             //end if
             //try local file system
             try {
                 $arr_cache_config = $arr_config["cache_filesystem_config_common"];
                 $arr_cache_config["adapter"]["options"]["cache_dir"] = $dir;
                 $cache = StorageFactory::factory($arr_cache_config);
             } catch (\Exception $e) {
                 throw new \Exception(__CLASS__ . " Line " . __LINE__ . " : External Form Cache could not create Redis of Filesystem cache", 500);
             }
             //end catch
         }
         //end catch
         $model_core_forms_cache = new MajesticExternalFormsCacheModel($cache);
         return $model_core_forms_cache;
     }));
 }
开发者ID:BanterMediaSA,项目名称:majestic3-open-source,代码行数:33,代码来源:Module.php

示例3: getServiceConfig

 public function getServiceConfig()
 {
     return ['factories' => ['Cache' => function ($sm) {
         // Trabalhando com APC
         $config = $sm->get('Config');
         $cache = StorageFactory::factory(['adapter' => ['name' => $config['cache']['adapter'], 'options' => ['ttl' => $config['cache']['ttl']]], 'plugins' => ['Serializer', 'exception_handler' => ['throw_exceptions' => $config['cache']['throw_exceptions']]]]);
         return $cache;
         /* Trabalhando com memcached
         
                             $factory = [
                                 'adapter' => [
                                     'name'    => 'Memcached',
                                     'options' => [
                                         'ttl' => 10,
                                         'servers' => [
                                             ['127.0.0.1', 11211]
                                         ]
                                     ],
                                 ],
                                 'plugins' => [
                                     'Serializer',
                                     'exception_handler' => ['throw_exceptions' => true],// em produção false
                                 ],
                             ];
                             $cache = StorageFactory::factory($factory);
                             return $cache;
                             */
     }]];
 }
开发者ID:argentinaluiz,项目名称:Learning-ZF2,代码行数:29,代码来源:Module.php

示例4: createService

 /**
  * Create Service
  *
  * @param ServiceLocatorInterface $serviceLocator Zend Service Manager
  *
  * @return \Zend\Cache\Storage\StorageInterface
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config');
     $extraOptions = ['namespace' => 'rcmRssCache', 'ttl' => '300'];
     $cache = StorageFactory::factory(['adapter' => ['name' => $config['rcmCache']['adapter'], 'options' => $config['rcmCache']['options'] + $extraOptions], 'plugins' => $config['rcmCache']['plugins']]);
     return $cache;
 }
开发者ID:reliv,项目名称:rcm-plugins,代码行数:14,代码来源:RssCacheFactory.php

示例5: setUp

 public function setUp()
 {
     $this->storage = StorageFactory::factory(array('adapter' => 'apc', 'options' => array()));
     $this->storage->flush();
     $services = bootstrap::getServiceManager();
     $services->setAllowOverride(true);
 }
开发者ID:netglue,项目名称:zf2-prismic-module,代码行数:7,代码来源:OverrideCacheTest.php

示例6: setUp

    public function setUp()
    {
        $this->_cacheDir = sys_get_temp_dir() . '/zend_locale_cldr';
        $this->_removeRecursive($this->_cacheDir);
        mkdir($this->_cacheDir);

        $this->_cache = CacheFactory::factory(array(
            'adapter' => array(
                'name' => 'Filesystem',
                'options' => array(
                    'ttl'       => 1,
                    'cache_dir' => $this->_cacheDir,
                )
            ),
            'plugins' => array(
                array(
                    'name' => 'serializer',
                    'options' => array(
                        'serializer' => 'php_serialize',
                    ),
                ),
            ),
        ));

        Cldr::setCache($this->_cache);
    }
开发者ID:necrogami,项目名称:zf2,代码行数:26,代码来源:CldrCachedTest.php

示例7: createService

 /**
  * {@inheritDoc}
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     /** @var $options \StrokerCache\Options\ModuleOptions */
     $options = $serviceLocator->get('StrokerCache\\Options\\ModuleOptions');
     $adapterOptions = array('adapter' => $options->getStorageAdapter());
     return StorageFactory::factory($adapterOptions);
 }
开发者ID:stefanorg,项目名称:zf2-fullpage-cache,代码行数:10,代码来源:CacheStorageFactory.php

示例8: __construct

 /**
  * @param array $configuration
  * @throws \Zend\Cache\Exception\InvalidArgumentException
  * @throws \Zend\Cache\Exception\RuntimeException
  */
 public function __construct(array $configuration)
 {
     if (!isset($configuration['adapter'])) {
         $configuration['adapter'] = 'Filesystem';
     }
     if (!isset($configuration['adapterOptions'])) {
         $configuration['adapterOptions'] = [];
     }
     $cache = StorageFactory::factory(['adapter' => ['name' => $configuration['adapter'], 'options' => $configuration['adapterOptions']]]);
     $options = $cache->getOptions();
     $options->setNamespace('Shariff');
     $options->setTtl($configuration['ttl']);
     if ($options instanceof FilesystemOptions) {
         $options->setCacheDir(isset($configuration['cacheDir']) ? $configuration['cacheDir'] : sys_get_temp_dir());
     }
     if ($cache instanceof ClearExpiredInterface) {
         if (function_exists('register_postsend_function')) {
             // for hhvm installations: executing after response / session close
             register_postsend_function(function () use($cache) {
                 $cache->clearExpired();
             });
         } else {
             // default
             $cache->clearExpired();
         }
     }
     $this->cache = $cache;
 }
开发者ID:hokascha,项目名称:shariff-backend-php,代码行数:33,代码来源:ZendCache.php

示例9: createService

 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return null|StorageInterface
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config');
     self::$cache = StorageFactory::factory(isset($config['cache']) ? $config['cache'] : array());
     //        self::$cache->flush();
     return self::$cache;
 }
开发者ID:athemcms,项目名称:athcore,代码行数:13,代码来源:CacheFactory.php

示例10: createService

 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('config');
     $cacheAdapterConfiguration = $config['validation_cache_adapter'];
     $cache = StorageFactory::factory($cacheAdapterConfiguration);
     return $cache;
 }
开发者ID:ibekiaris,项目名称:zf2-annotation-validator,代码行数:13,代码来源:AnnotationsValidatorCacheAdapterFactory.php

示例11: __invoke

 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $this->prepareStorageFactory($container);
     $config = $container->get('config');
     $cacheConfig = isset($config['cache']) ? $config['cache'] : [];
     return StorageFactory::factory($cacheConfig);
 }
开发者ID:stephenmoore56,项目名称:mooredatabase-laravel,代码行数:7,代码来源:StorageCacheFactory.php

示例12: setUp

 public function setUp()
 {
     $this->_originaltimezone = date_default_timezone_get();
     date_default_timezone_set('Europe/Paris');
     $this->_cache = CacheFactory::factory(array('adapter' => array('name' => 'filesystem', 'options' => array('ttl' => 120)), 'plugins' => array(array('name' => 'serializer', 'options' => array('serializer' => 'php_serialize')))));
     DateObjectTestHelper::setOptions(array('cache' => $this->_cache));
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:7,代码来源:DateObjectTest.php

示例13: registerFactories

 public function registerFactories()
 {
     $this->createFactoryObject("Zend\\Cache\\Storage\\Adapter\\Memcached", function () {
         $memcached = $this->configManager->getMemcached();
         return StorageFactory::factory(array('adapter' => array('name' => 'memcached', 'options' => array('servers' => array(array($memcached['Host'], $memcached['Port']))))));
     });
 }
开发者ID:marcyniu,项目名称:ai,代码行数:7,代码来源:Container.php

示例14: getCacheAdapter

 /**
  * Return the sed Cache adapter.
  *
  * @return mixed|StorageInterface
  */
 public function getCacheAdapter()
 {
     if (null == $this->storageAdapter) {
         $this->storageAdapter = StorageFactory::factory($this->options['cache']);
     }
     return $this->storageAdapter;
 }
开发者ID:athemcms,项目名称:athcore,代码行数:12,代码来源:CachedCompiler.php

示例15: setup

 public function setup()
 {
     $sl = bootstrap::getServiceManager();
     $this->sitemap = $sl->get('NetgluePrismic\\Service\\Sitemap');
     $this->cache = StorageFactory::factory(array('adapter' => 'apc', 'options' => array()));
     $this->cache->flush();
 }
开发者ID:netglue,项目名称:zf2-prismic-module,代码行数:7,代码来源:SitemapTest.php


注:本文中的Zend\Cache\StorageFactory::factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。