ZF2 & Doctrine ORM - 如何关闭 DoctrineModule 缓存
ZF2 & Doctrine ORM - How to turn off the DoctrineModule cache
我一直在想如何在我的开发环境中打开和关闭 DoctrineModule 缓存。
目前我的查询被缓存并存储在 data/DoctrineModule/cache 文件夹中,当错误测试时这可能会导致便秘 :)
基本上我想为我的生产环境设置缓存并为我的开发环境关闭缓存,显然要做到这一点我需要正确的配置设置并有一个 local/global 配置设置来处理有了这个。
这是文件存储位置的屏幕截图:
以下是我的测试配置文件:
<?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);
},
],
],
]
];
我确定我需要添加一个配置,虽然我不确定是哪一个。
谢谢!
好的,这已经解决了。
在我的 module.config.php 文件中,我将 doctrine 驱动程序设置为缓存 => 文件系统,我将其更改为数组,现在问题已解决。
'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'
]
]
],
],
我一直在想如何在我的开发环境中打开和关闭 DoctrineModule 缓存。
目前我的查询被缓存并存储在 data/DoctrineModule/cache 文件夹中,当错误测试时这可能会导致便秘 :)
基本上我想为我的生产环境设置缓存并为我的开发环境关闭缓存,显然要做到这一点我需要正确的配置设置并有一个 local/global 配置设置来处理有了这个。
这是文件存储位置的屏幕截图:
以下是我的测试配置文件:
<?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);
},
],
],
]
];
我确定我需要添加一个配置,虽然我不确定是哪一个。
谢谢!
好的,这已经解决了。
在我的 module.config.php 文件中,我将 doctrine 驱动程序设置为缓存 => 文件系统,我将其更改为数组,现在问题已解决。
'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'
]
]
],
],