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


PHP Adapter\AbstractAdapter类代码示例

本文整理汇总了PHP中Zend\Cache\Storage\Adapter\AbstractAdapter的典型用法代码示例。如果您正苦于以下问题:PHP AbstractAdapter类的具体用法?PHP AbstractAdapter怎么用?PHP AbstractAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: checkPreEventCanChangeArguments

 protected function checkPreEventCanChangeArguments($method, array $args, array $expectedArgs)
 {
     $internalMethod = 'internal' . ucfirst($method);
     $eventName = $method . '.pre';
     // init mock
     $this->_storage = $this->getMockForAbstractAdapter(array($internalMethod));
     $this->_storage->getEventManager()->attach($eventName, function ($event) use($expectedArgs) {
         $params = $event->getParams();
         foreach ($expectedArgs as $k => $v) {
             $params[$k] = $v;
         }
     });
     // set expected arguments of internal method call
     $tmp = $this->_storage->expects($this->once())->method($internalMethod);
     $equals = array();
     foreach ($expectedArgs as $v) {
         $equals[] = $this->equalTo($v);
     }
     call_user_func_array(array($tmp, 'with'), $equals);
     // run
     call_user_func_array(array($this->_storage, $method), $args);
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:22,代码来源:AbstractAdapterTest.php

示例2: getSizes

 /**
  * Returns sizes array for photo identified by Flickr photo id
  *
  * @param  int   $photoId
  * @return array Array of photo size information
  */
 public function getSizes($photoId)
 {
     $sizes = $this->adapter->getItem($photoId);
     if (is_null($sizes)) {
         $sizes = $this->flickr->getSizes($photoId);
         $this->adapter->addItem($photoId, $sizes);
     }
     return $sizes;
 }
开发者ID:neophyt3,项目名称:flaming-archer,代码行数:15,代码来源:FlickrServiceCache.php

示例3: setOptions

 /**
  * Set options.
  *
  * @param  array|\Traversable|SessionOptions $options
  * @return Memory
  * @see    getOptions()
  */
 public function setOptions($options)
 {
     if (!$options instanceof SessionOptions) {
         $options = new SessionOptions($options);
     }
     return parent::setOptions($options);
 }
开发者ID:eltondias,项目名称:Relogio,代码行数:14,代码来源:Session.php

示例4: manageAction

 /**
  * All a user to add and update a feed in the application
  *
  * @return ViewModel
  */
 public function manageAction()
 {
     $formManager = $this->serviceLocator->get('FormElementManager');
     $form = $formManager->get('BabyMonitor\\Forms\\ManageRecordForm');
     $feedId = (int) $this->params()->fromRoute('id');
     if ($this->getRequest()->isGet()) {
         if (!empty($feedId)) {
             if ($feed = $this->_feedTable->fetchById($feedId)) {
                 $form->setData($feed->getArrayCopy());
             } else {
                 $this->flashMessenger()->addInfoMessage('Unable to find that feed. Perhaps a new one?');
                 return $this->redirect()->toRoute(self::DEFAULT_ROUTE, array('action' => 'manage'));
             }
         }
     }
     if ($this->getRequest()->isPost()) {
         $form->setData($this->getRequest()->getPost());
         if ($form->isValid()) {
             $feed = new FeedModel();
             $feed->exchangeArray($form->getData());
             $this->_feedTable->save($feed);
             if (!is_null($this->_cache)) {
                 $this->_cache->removeItem(self::KEY_ALL_RESULTS);
             }
             $this->getEventManager()->trigger('Feed.Modify', $this, array('feedData' => $feed));
             return $this->redirect()->toRoute(self::DEFAULT_ROUTE, array());
         }
     }
     return new ViewModel(array('form' => $form, 'cancelTitle' => $feedId ? "Don't update the record" : "Don't create the record", 'messages' => array('info' => $this->flashMessenger()->hasInfoMessages())));
 }
开发者ID:rawatanil3,项目名称:zf2forbeginners-old,代码行数:35,代码来源:FeedsController.php

示例5: setOptions

 /**
  * Set options.
  *
  * @param  array|Traversable|WinCacheOptions $options
  * @return WinCache
  * @see    getOptions()
  */
 public function setOptions($options)
 {
     if (!$options instanceof WinCacheOptions) {
         $options = new WinCacheOptions($options);
     }
     return parent::setOptions($options);
 }
开发者ID:CHRISTOPHERVANDOMME,项目名称:zf2complet,代码行数:14,代码来源:WinCache.php

示例6: setOptions

 /**
  * Set options.
  *
  * @param  array|\Traversable|MemoryOptions $options
  * @return Memory
  * @see    getOptions()
  */
 public function setOptions($options)
 {
     if (!$options instanceof MemoryOptions) {
         $options = new MemoryOptions($options);
     }
     return parent::setOptions($options);
 }
开发者ID:nuklehed,项目名称:zf2,代码行数:14,代码来源:Memory.php

示例7: setOptions

 /**
  * Set options.
  *
  * @param  array|Traversable|ApcOptions $options
  * @return Apc
  * @see    getOptions()
  */
 public function setOptions($options)
 {
     if (!$options instanceof ApcOptions) {
         $options = new ApcOptions($options);
     }
     return parent::setOptions($options);
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:14,代码来源:Apc.php

示例8: persist

 /**
  * @param $entity
  *
  * @return mixed
  * @throws \InvalidArgumentException If the ResultSetPrototype is not Hydrating
  * @throws \InvalidArgumentException If a BaseEntity object is not provided
  */
 public function persist($entity)
 {
     if (!$this->getResultSetPrototype() instanceof HydratingResultSet) {
         throw new \InvalidArgumentException('Result Set Prototype is not configured correctly');
     }
     if (!$entity instanceof BaseEntity) {
         throw new \InvalidArgumentException('Can only persist object entities');
     }
     $hydrator = $this->getResultSetPrototype()->getHydrator();
     $data = $hydrator->extract($entity);
     $sql = $this->getSql();
     $identifierName = $this->getIdentifierName();
     $identifier = null;
     if (array_key_exists($identifierName, $data)) {
         $identifier = $data[$identifierName];
         unset($data[$identifierName]);
     }
     array_walk($data, function (&$value) {
         if ($value instanceof \DateTime) {
             $value = $value->format('Y-m-d H:i:s');
         }
     });
     if (!empty($identifier)) {
         // UPDATE
         $data['lastModified'] = date('Y-m-d H:i:s');
         $where = array();
         $where[$identifierName] = $identifier;
         $statement = $sql->prepareStatementForSqlObject($sql->update()->set($data)->where($where));
         $result = $statement->execute();
         unset($statement, $result);
         // cleanup
     } else {
         // INSERT
         $data['createdDatetime'] = date('Y-m-d H:i:s');
         $data['status'] = '1';
         $data['lastModified'] = date('Y-m-d H:i:s');
         $insert = $sql->insert();
         $insert->values($data);
         $statement = $sql->prepareStatementForSqlObject($insert);
         $result = $statement->execute();
         $identifier = $result->getGeneratedValue();
         unset($statement, $result);
         // cleanup
         $where = array();
         $where[$identifierName] = $identifier;
     }
     // refresh data
     $statement = $sql->prepareStatementForSqlObject($this->sql->select()->where($where));
     $result = $statement->execute();
     $rowData = $result->current();
     unset($statement, $result);
     // cleanup
     $hydrator->hydrate($rowData, $entity);
     if ($this->cacheAdapter instanceof CacheAdapter) {
         $this->cacheAdapter->setItem($this->getCacheKeyHash($entity->getId()), $entity);
     }
     return $entity;
 }
开发者ID:nobesnickr,项目名称:ApiTimesheets,代码行数:65,代码来源:TableGatewayService.php

示例9: build

 /**
  * @inheritdoc
  */
 public function build()
 {
     if ($this->built) {
         return;
     }
     $key = 'assets-manager';
     if ($this->cacheAdapter->hasItem($key)) {
         $data = $this->cacheAdapter->getItem($key);
         $assetManager = unserialize($data);
         if ($assetManager instanceof AssetManager) {
             $this->setAssetManager($assetManager);
             return;
         }
     }
     parent::build();
     $this->cacheAdapter->setItem($key, serialize($this->getAssetManager()));
     $this->built = true;
 }
开发者ID:enlitepro,项目名称:enlite-assetic,代码行数:21,代码来源:Service.php

示例10: flush

 /**
  * Flush the whole storage
  *
  * @return bool
  */
 public function flush()
 {
     if (!$this->cache instanceof FlushableInterface) {
         return false;
     }
     try {
         return $this->cache->flush();
     } catch (ZendException\ExceptionInterface $ex) {
         return false;
     }
 }
开发者ID:gunnilx,项目名称:WurflCache,代码行数:16,代码来源:ZendCacheConnector.php

示例11: clearItem

 /**
  * Remove an item from the cache
  * @param string $key
  * @return boolean
  */
 public function clearItem($key)
 {
     //check if caching is enabled
     $arr_config = $this->getServiceLocator()->get("config");
     if ($arr_config["front_end_application_config"]["cache_enabled"] == FALSE) {
         return FALSE;
     }
     //end if
     //adjust key
     $key = $this->setIdentifier($key);
     $this->storageFactory->removeItem($key);
 }
开发者ID:BanterMediaSA,项目名称:majestic3-open-source,代码行数:17,代码来源:FrontCachesAbstract.php

示例12: __construct

 /**
  * Constructor
  *
  * @param  array|Traversable|WinCacheOptions $options
  * @throws Exception
  * @return void
  */
 public function __construct($options = null)
 {
     if (!extension_loaded('wincache')) {
         throw new Exception\ExtensionNotLoadedException("WinCache extension is not loaded");
     }
     $enabled = ini_get('wincache.ucenabled');
     if (PHP_SAPI == 'cli') {
         $enabled = $enabled && (bool) ini_get('wincache.enablecli');
     }
     if (!$enabled) {
         throw new Exception\ExtensionNotLoadedException("WinCache is disabled - see 'wincache.ucenabled' and 'wincache.enablecli'");
     }
     parent::__construct($options);
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:21,代码来源:WinCache.php

示例13: onFinish

 /**
  * Cache Response for future requests
  *
  * @param MvcEvent $e
  * @return \Zend\Stdlib\ResponseInterface
  */
 public function onFinish(MvcEvent $e)
 {
     $request = $e->getRequest();
     if (!$request instanceof HttpRequest) {
         return;
     }
     if (!$request->isGet()) {
         return;
     }
     $response = $e->getResponse();
     if ($response instanceof HttpResponse && !$response->isOk()) {
         return;
     }
     // Do not continue if weren't able to compose a key
     if (empty($this->cache_key)) {
         return;
     }
     if (!$this->cacheAdapter->hasItem($this->cache_key)) {
         $resourceIdentifier = $e->getRouteMatch()->getParam('resource');
         $resource = call_user_func($this->getResourceLocatorService(), $resourceIdentifier);
         if (!$resource instanceof Resource || !$resource->isCacheable()) {
             return;
         }
         // Generate Response cache headers based on Resource CacheOptions
         $cacheOptions = $resource->getCacheOptions();
         $cacheControl = new CacheControl();
         $cacheControl->addDirective($cacheOptions->getAccess());
         $cacheControl->addDirective('max-age', $cacheOptions->getMaxAge());
         $cacheControl->addDirective('expires', $cacheOptions->getExpires());
         $cacheControl->addDirective('must-revalidate');
         $dateTime = new \DateTime();
         $dateTime->modify('+ ' . $cacheOptions->getExpires() . 'seconds');
         $expires = new Expires();
         $expires->setDate($dateTime);
         $lastModified = new LastModified();
         $lastModified->setDate(new \DateTime());
         // Add Headers to Response Header
         $response->getHeaders()->addHeader($cacheControl);
         $response->getHeaders()->addHeader($expires);
         $response->getHeaders()->addHeaderLine('Pragma: ' . $cacheOptions->getAccess());
         $response->getHeaders()->addHeader(Etag::fromString('Etag: ' . md5($response->getBody())));
         $response->getHeaders()->addHeader($lastModified);
         // Set cache adapter's TTL using Resource cache expires value
         $this->cacheAdapter->getOptions()->setTtl($cacheOptions->getExpires());
         $this->cacheAdapter->setItem($this->cache_key, $response);
         //return $response;
     }
 }
开发者ID:parrotcage,项目名称:aves,代码行数:54,代码来源:ResponseCacheListenerAggregate.php

示例14: __construct

 /**
  * Constructor
  *
  * @param  null|array|Traversable|MemcachedOptions $options
  * @throws Exception
  * @return void
  */
 public function __construct($options = null)
 {
     if (static::$extMemcachedMajorVersion === null) {
         $v = (string) phpversion('memcached');
         static::$extMemcachedMajorVersion = $v !== '' ? (int) $v[0] : 0;
     }
     if (static::$extMemcachedMajorVersion < 1) {
         throw new Exception\ExtensionNotLoadedException('Need ext/memcached version >= 1.0.0');
     }
     $this->memcached = new MemcachedResource();
     parent::__construct($options);
     // It's ok to add server as soon as possible because
     // ext/memcached auto-connects to the server on first use
     // TODO: Handle multiple servers
     $options = $this->getOptions();
     $this->memcached->addServer($options->getServer(), $options->getPort());
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:24,代码来源:Memcached.php

示例15: __construct

 /**
  * Constructor
  *
  * @param  null|array|Traversable|ApcOptions $options
  * @throws Exception
  * @return void
  */
 public function __construct($options = null)
 {
     if (version_compare('3.1.6', phpversion('apc')) > 0) {
         throw new Exception\ExtensionNotLoadedException("Missing ext/apc >= 3.1.6");
     }
     $enabled = ini_get('apc.enabled');
     if (PHP_SAPI == 'cli') {
         $enabled = $enabled && (bool) ini_get('apc.enable_cli');
     }
     if (!$enabled) {
         throw new Exception\ExtensionNotLoadedException("ext/apc is disabled - see 'apc.enabled' and 'apc.enable_cli'");
     }
     // init select map
     if (static::$selectMap === null) {
         static::$selectMap = array('value' => \APC_ITER_VALUE, 'mtime' => \APC_ITER_MTIME, 'ctime' => \APC_ITER_CTIME, 'atime' => \APC_ITER_ATIME, 'rtime' => \APC_ITER_DTIME, 'ttl' => \APC_ITER_TTL, 'num_hits' => \APC_ITER_NUM_HITS, 'ref_count' => \APC_ITER_REFCOUNT, 'mem_size' => \APC_ITER_MEM_SIZE, 'internal_key' => \APC_ITER_KEY);
     }
     parent::__construct($options);
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:25,代码来源:Apc.php


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