Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Zend framework2 APC缓存适配器-唯一?_Zend Framework2 - Fatal编程技术网

Zend framework2 APC缓存适配器-唯一?

Zend framework2 APC缓存适配器-唯一?,zend-framework2,Zend Framework2,也许我现在还没有完全理解文档,但是有没有办法设置一个唯一的标识符,这样我缓存的翻译就不会被覆盖 每个域都有相同的命名空间 以下是我到目前为止在module.config.php中的内容 'translator' => array( 'locale' => 'en', 'translation_file_patterns' => array( array( 'type' =

也许我现在还没有完全理解文档,但是有没有办法设置一个唯一的标识符,这样我缓存的翻译就不会被覆盖

每个域都有相同的命名空间

以下是我到目前为止在module.config.php中的内容

'translator' => array(
    'locale'                    => 'en',
    'translation_file_patterns' => array(
        array(
            'type'        => 'gettext',
            'base_dir'    => __DIR__ . '/../language',
            'pattern'     => '%s.mo',
            'text_domain' => 'ftp'
        )
    ),
    'cache' => \Zend\Cache\StorageFactory::factory(array(
        'adapter' => 'apc',
        'plugins' => array(
            'exception_handler' => array(
                'throw_exceptions' => false
            )
        )
    ))
)
现在我有两个Apache VirtualHost在同一台机器上运行,每个VirtualHost中都有一个名为Ftp的模块,每个模块都使用Ftp文本_域来翻译自己的翻译

假设我有一个名为translate_this_text的翻译键,它在两个域上都使用

在domain1.com上它会读到Test1 在domain2.com上它会读到Test2

如果我访问domain1.com,文本将转换为Test1 如果我访问domain2.com,文本将转换为Test1,但这应该是Test2

如果我清除APC缓存并访问domain2.com,则转换显示Test2,但如果我访问domain1.com,则显示Test2

我希望这不会太令人困惑


最后,有没有办法在每台主机上设置某种类型的唯一标识符,这样它们就不会相互覆盖,因为它们现在存在于同一台机器上?

用数组替换
适配器
值,以便您可以向APC适配器中插入选项:

'translator' => array(
    'cache' => \Zend\Cache\StorageFactory::factory(array(
        'adapter' => array(
            'name'    => 'apc',
            'options' => array(
                'namespace' => 'foo_bar',
            ),
        ),
        'plugins' => array(
            'exception_handler' => array(
                'throw_exceptions' => false
            )
        )
    ))
)
我会在上面写config而不在全局文件中输入
名称空间
键,然后在
config.local.php
中添加以下规则:

$cache_namespace = 'foo_bar';

'translator' => array(
    'cache' => \Zend\Cache\StorageFactory::factory(array(
        'adapter' => array(
            'options' => array(
                'namespace' => $cache_namespace,
            ),
        ),
    ))
)
对于每个应用程序,您只需编辑本地配置文件并共享全局缓存选项