當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Cache\StorageFactory類代碼示例

本文整理匯總了PHP中Zend\Cache\StorageFactory的典型用法代碼示例。如果您正苦於以下問題:PHP StorageFactory類的具體用法?PHP StorageFactory怎麽用?PHP StorageFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了StorageFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例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: __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

示例7: 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

示例8: 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

示例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

 /**
  * {@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

示例11: 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

示例12: 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

示例13: __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

示例14: cacheClear

 /**
  * Defined by Zend\Authentication\Storage\StorageInterface
  *
  * @return void
  */
 public function cacheClear()
 {
     $userId = $this->session->{$this->member}->userId;
     $cache = StorageFactory::factory(array('adapter' => array('name' => 'filesystem', 'options' => array('cache_dir' => './data/cache', 'ttl' => 3600)), 'plugins' => array('exception_handler' => array('throw_exceptions' => false), 'serializer')));
     foreach ($this->remove_caches as $cache_ns) {
         $cache->removeItem($cache_ns . $userId);
     }
 }
開發者ID:khinmyatkyi,項目名稱:Office_Management,代碼行數:13,代碼來源:SundewAuthStorage.php

示例15: __construct

 public function __construct($path = '../cache')
 {
     if (!is_dir($path) && !mkdir($path, 0755, true)) {
         throw new \Exception('Cache path doesn\'t exist');
     }
     $this->path = $path;
     $this->cache = StorageFactory::factory(array('adapter' => array('name' => 'filesystem', 'options' => array('ttl' => 3600, 'cache_dir' => $path, 'dir_level' => 1, 'dir_permission' => 0755, 'file_permission' => 0644)), 'plugins' => array('exception_handler' => array('throw_exceptions' => false), 'serializer')));
 }
開發者ID:debuger,項目名稱:gsp,代碼行數:8,代碼來源:GetSinglePage.php


注:本文中的Zend\Cache\StorageFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。