如何使用原则 2 文件系统缓存宽度 Zend 2.


How to use Doctrine 2 FileSystemCache width Zend 2

我目前正在做一个Zend 2项目,想使用Doctrines FilesystemCache。

在我的模块.config中.php我有以下几行:

'doctrine'           => array(
    'driver' => array(
        __NAMESPACE__ . '_driver'    => array(
            'class'  => 'Doctrine'ORM'Mapping'Driver'AnnotationDriver',
            'cache' => array(
                'filesystem' => array(
                    'class' => ''Doctrine'Common'Cache'FilesystemCache',
                    'directory' => __DIR__ . '/../data/cache/' . __NAMESPACE,
                )
            )
            'paths'  => array(__DIR__ . '/../src/' . __NAMESPACE__ . '  /Entity')
        ),
        'orm_default'                => array(
            'drivers' => array(
                __NAMESPACE__ . ''Entity' => __NAMESPACE__ .    '_driver'
            )
        )
    ),

使用上述配置,我的实体不会被缓存,它给了我以下通知:

数组到字符串的转换在/webroot/vendor/doctrine/doctrine-module/src/DoctrineModule/Options/Driver.php第 90 行

当我将我的配置更改为仅一个字符串时:

'cache' => 'filesystem'

我看到文件系统缓存尝试将我的实体缓存到默认位置 (?),但失败并显示如下警告:

警告:file_put_contents(/var/www/webroot/data/DoctrineModule/cache/e4165aec32e5/87e827598d3b/bdef3af2/[File''Entity''File$name@[Annot]][1].doctrinecache.data):无法打开流:第 111 行/var/www/webroot/vendor/doctrine/common/lib/Doctrine/Common/Cache/FilesystemCache.php 中的参数无效

可能你应该使用常量而不是__NAMESPACE__ __NAMESPACE

没有这样的目录