Home> php教程> PHP开发> body text

Zend Framework cache Cache usage simple example

高洛峰
Release: 2017-01-05 10:56:08
Original
1231 people have browsed it

The example in this article describes the usage of Zend Framework cache Cache. Share it with everyone for your reference, the details are as follows:

cache->cache->frontend->toArray(); $backendOptions = $config->cache->cache->backend->toArray(); $frontendName = $frontendOptions['name']; unset($frontendOptions['name']); $backendName = $backendOptions['name']; unset($backendOptions['name']); if (empty($backendOptions['cache_dir'])) { $backendOptions['cache_dir'] = CACHE_DIR; } $_cache = Zend_Cache::factory($frontendName, $backendName, $frontendOptions, $backendOptions); Zend_Registry::set('cache', $_cache); /*使用cache*/ $viewRenderer = $_cache->load('viewRenderer'); //试图从缓存加载变量 if (!$viewRenderer instanceof Something)//加载不成功 { $viewRenderer = new Something(); /*some other work*/ $_cache->save($viewRenderer, 'viewRenderer');//保存变量到换存 } /*这只是一种应用,还可以轻松缓存整页;也可将缓存存到数据库或者内存。*/ ?>
Copy after login

I hope this article will be helpful to everyone’s PHP programming based on the Zend Framework framework.

For more articles related to simple examples of Zend Framework cache Cache usage, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!