ZF2& Doctrine ORM - 如何关闭DoctrineModule缓存

时间:2015-04-18 17:37:18

标签: doctrine-orm zend-framework2

我一直想知道如何在我的开发环境中打开和关闭DoctrineModule缓存。

目前我的查询被缓存并存储在data / DoctrineModule / cache文件夹中,当bug测试时会导致便秘:)

基本上我想为我的生产环境设置缓存并关闭我的开发环境,显然我需要对配置进行正确的设置,并有一个本地/全局配置设置来处理这个问题。 / p>

以下是存储文件的屏幕截图:

enter image description here

以下是我的测试配置文件:

<?php
return [
    'doctrine' => [
        'connection' => [
            'orm_default' => [
                'driverClass' =>'Doctrine\DBAL\Driver\PDOMySql\Driver',
                'params' => [
                    'host'     => 'localhost',
                    'port'     => '3306',
                    'user'     => 'pw1',
                    'password' => 'pw1',
                    'dbname'   => 'server',
                    'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock'   //To use Doctrine Entity Generator
                ]
            ]
        ],
        'eventmanager' => [
            'orm_default' => [
                'subscribers' => [
                    'Gedmo\Timestampable\TimestampableListener',
                ],
            ],
        ],
        'configuration' => [
            'orm_default' => [
                'naming_strategy' => 'UnderscoreNamingStrategy',
            ],
        ],
        'authentication' => [
            'orm_default' => [
                'object_manager' => 'Doctrine\ORM\EntityManager',
                'identity_class' => 'RoleBasedUser\Entity\User',
                'identity_property' => 'email',
                'credential_property' => 'password',
                'credential_callable' => function(\RoleBasedUser\Entity\User $user, $passwordGiven) {
                        $hashedPassword  = $user->getPassword();
                        $passwordService = new \RoleBasedUser\Service\PasswordService();
                        return $passwordService->verify($passwordGiven, $hashedPassword);

                    },
            ],
        ],
    ]
];

我确定我需要添加一个配置,虽然我不确定。

谢谢!

1 个答案:

答案 0 :(得分:0)

好的,这已经解决了。

在我的module.config.php文件中,我将doctrine驱动程序设置为cache =&gt;文件系统,我改为数组,问题现在已经解决了。

'doctrine'           => [
    'driver' => [
        'RBU_driver'  => [
            'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
            //cache => 'filesystem',  <-- this will cache into the data/DoctrineModule
            'cache' => 'array', //<-- this will not cache...
            'paths' => [
                __DIR__ . '/../src/RoleBasedUser/Entity'
            ]
        ],
        'orm_default' => [
            'drivers' => [
                'RoleBasedUser\Entity' => 'RBU_driver'
            ]
        ]
    ],
],