添加缓存来的Zend \\表格\\注解\\ AnnotationBuilder [英] Add caching to Zend\Form\Annotation\AnnotationBuilder

查看:108
本文介绍了添加缓存来的Zend \\表格\\注解\\ AnnotationBuilder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我终于在Windows上找到内存缓存的二进制为PHP 5.4.4,我加快了我目前正在开发的应用程序。

As I've finally found a binary of memcache for PHP 5.4.4 on Windows, I'm speeding up the application I'm currently developing.

我已经成功设置的memcache作为学说ORM映射缓存驱动程序,但我需要解决的另一个泄漏:用表格注释建

I've succeeded setting memcache as Doctrine ORM Mapping Cache driver, but I need to fix another leakage: Forms built using annotations.

我按的文档。不幸的是,这需要大量的时间,对于单页创建多个形式特别是当

I'm creating forms according to the Annotations section of the docs. Unfortunately, this takes a lot of time, especially when creating multiple forms for a single page.

是否可以缓存到这个进程?我已经通过了code浏览,但它似乎像的Zend \\表格\\注释\\ AnnotationBuilder 总是反映code和解析注释创建窗体。先谢谢了。

Is it possible to add caching to this process? I've browsed through the code but it seems like the Zend\Form\Annotation\AnnotationBuilder always creates the form by reflecting the code and parsing the annotations. Thanks in advance.

推荐答案

您可能想尝试这样的:

class ZendFormCachedController extends Zend_Controller_Action
{
    protected $_formId = 'form';

    public function indexAction()
    {
            $frontend = array(
                    'lifetime' => 7200,
                    'automatic_serialization' => true);

            $backend = array('cache_dir' => '/tmp/');
            $cache = Zend_Cache::factory('Core', 'File', $frontend, $backend);

            if ($this->getRequest()->isPost()) {
                    $form = $this->getForm(new Zend_Form);
            } else if (! $form = $cache->load($this->_formId)) {
                    $form = $this->getForm(new Zend_Form);
                    $cache->save($form->__toString(), $this->_formId);
            }

            $this->getHelper('layout')->setLayout('zend-form');
            $this->view->form = $form;
    }

这里。

这篇关于添加缓存来的Zend \\表格\\注解\\ AnnotationBuilder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆