如何在Symfony,Doctrine ORM和DoctrineCacheBundle中使用ApcuCache [英] How to use ApcuCache with Symfony, Doctrine ORM and DoctrineCacheBundle

查看:99
本文介绍了如何在Symfony,Doctrine ORM和DoctrineCacheBundle中使用ApcuCache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我被这个问题困扰之前,该项目是在SF2.6的PHP5.6上运行的.

before i was stuck with this problem the project was running on PHP5.6 on SF2.6.

现在我在SF2.8中使用PHP7.1.20.我在docker容器中同时安装了apcu和apcu_bc并启用了apcu php模块.

now im using PHP7.1.20 with SF2.8. i installed apcu along with apcu_bc inside my docker container and enabled the apcu php module.

现在错误是:

UndefinedFunctionException in ApcCache.php line 35:
Attempted to call function "apc_exists" from the global namespace.

当我将已加载的ApcCache-Class内部的实际函数调用从apc_更改为apcu_时,一切正常.

when i change the actual function calls inside of the loaded ApcCache-Class from apc_ to apcu_ everything works fine.

都是ApcCache-和ApcuCache-Class这两个类.我不知道如何告诉原则ORM/CacheBundle使用ApcuCache-Class而不是Apc.

inside Doctrine\Common\Cache are both classes, the ApcCache- and the ApcuCache-Class. i dont know how i can tell doctrine ORM/CacheBundle to use the ApcuCache-Class instead of the Apc one.

Doctrine Config:

Doctrine Config:

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                driver:   "%database_driver%"
                host:     "%database_host%"
                port:     "%database_port%"
                dbname:   "%database_name%"
                user:     "%database_user%"
                password: "%database_password%"
                charset:  UTF8
                persistent: true
                wrapper_class: 'Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection'
                driver_class: 'Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Driver\PDOMySql\Driver'
                server_version: '5.7'
                options:
                    x_reconnect_attempts: 3
            jato:
                driver:   "%database_jato_driver%"
                host:     "%database_jato_host%"
                port:     "%database_jato_port%"
                dbname:   "%database_jato_name%"
                user:     "%database_jato_user%"
                password: "%database_jato_password%"
                charset:  UTF8
                persistent: true
                server_version: '5.7'

            drupal:
                driver:   "%database_drupal_driver%"
                host:     "%database_drupal_host%"
                port:     "%database_drupal_port%"
                dbname:   "%database_drupal_name%"
                user:     "%database_drupal_user%"
                password: "%database_drupal_password%"
                charset:  UTF8
                persistent: true
                server_version: '5.7'

        types:
            json: Sonata\Doctrine\Types\JsonType

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        default_entity_manager: default
        entity_managers:
            default:
                connection: default
                mappings:
                    SonataMediaBundle: ~
                    ApplicationSonataMediaBundle: ~
                    XFrontendBundle: ~
                query_cache_driver:
                    type: service
                    id: doctrine_cache.providers.chain_cache
                metadata_cache_driver:
                    type: service
                    id: doctrine_cache.providers.chain_cache
                result_cache_driver:
                    type: service
                    id: doctrine_cache.providers.chain_cache

            jato:
                connection: jato
                mappings:
                    XBackendBundle: ~
                query_cache_driver: array
                metadata_cache_driver: array
                result_cache_driver: array
            drupal:
                connection: drupal

DoctrineCacheBundle配置:

DoctrineCacheBundle Config:

doctrine_cache:
    providers:
        chain_cache:
            chain:
                providers: [array_cache, apc_cache]
        apc_cache:
            type: apc
        array_cache:
            type: array

在缓存的服务容器(app/cache/prod/appProdProjectContainer.php)内,我可以找到以下信息:

inside the cached service container (app/cache/prod/appProdProjectContainer.php) i can find following information:

'doctrine_cache.providers.apc_cache' => 'getDoctrineCache_Providers_ApcCacheService',

之后

/*
     * Gets the public 'doctrine_cache.providers.apc_cache' shared service.
     *
     * @return \Doctrine\Common\Cache\ApcCache
     */
    protected function getDoctrineCache_Providers_ApcCacheService()
    {
        return $this->services['doctrine_cache.providers.apc_cache'] = new \Doctrine\Common\Cache\ApcCache();
    }

 'validator.mapping.cache.apc.class' => 'Symfony\\Component\\Validator\\Mapping\\Cache\\ApcCache',

'doctrine_cache.apc.class' => 'Doctrine\\Common\\Cache\\ApcCache',
'doctrine.orm.cache.apc.class' => 'Doctrine\\Common\\Cache\\ApcCache',

我需要配置或更新什么以实现仅使用ApcuCache-Class而不是Apc.

what do i need to configure or update etc to achieve that only the ApcuCache-Class gets used instead of Apc.

其他作曲家信息:

doctrine/cache                           v1.8.0
doctrine/annotations                     v1.6.0             
doctrine/cache                           v1.8.0             
doctrine/collections                     v1.5.0             
doctrine/common                          v2.9.0             
doctrine/dbal                            v2.4.5             
doctrine/doctrine-bundle                 1.6.13             
doctrine/doctrine-cache-bundle           dev-master 
doctrine/event-manager                   v1.0.0             
doctrine/inflector                       v1.3.0             
doctrine/instantiator                    1.1.0              
doctrine/lexer                           v1.0.1             
doctrine/orm                             v2.4.8             
doctrine/persistence                     v1.0.1             
doctrine/reflection                      v1.0.0  

symfony/assetic-bundle                   v2.8.2             
symfony/monolog-bundle                   v2.12.1           
symfony/polyfill-apcu                    v1.9.0             
symfony/polyfill-ctype                   v1.9.0             
symfony/polyfill-intl-icu                v1.9.0             
symfony/polyfill-mbstring                v1.9.0             
symfony/polyfill-php54                   v1.9.0             
symfony/polyfill-php55                   v1.9.0             
symfony/polyfill-php56                   v1.9.0             
symfony/polyfill-php70                   v1.9.0             
symfony/polyfill-util                    v1.9.0             
symfony/security-acl                     v3.0.1             
symfony/swiftmailer-bundle               v2.6.7             
symfony/symfony                          v2.8.45

sonata-project/admin-bundle              3.39.0             
sonata-project/block-bundle              3.12.1             
sonata-project/cache                     2.0.1              
sonata-project/core-bundle               3.11.2             
sonata-project/datagrid-bundle           2.3.1              
sonata-project/doctrine-extensions       1.0.2              
sonata-project/doctrine-orm-admin-bundle 3.4.2              
sonata-project/easy-extends-bundle       2.5.0              
sonata-project/exporter                  1.9.1              
sonata-project/formatter-bundle          3.5.0              
sonata-project/intl-bundle               2.5.0              
sonata-project/jquery-bundle             1.10.2             
sonata-project/markitup-bundle           2.1.0              
sonata-project/media-bundle              3.15.0 

容器调试信息:

Information for Service "doctrine_cache.providers.apc_cache"
============================================================

 ------------------ ------------------------------------
  Option             Value
 ------------------ ------------------------------------
  Service ID         doctrine_cache.providers.apc_cache
  Class              Doctrine\Common\Cache\ApcCache
  Tags               -
  Scope              container
  Public             yes
  Synthetic          no
  Lazy               no
  Synchronized       no
  Abstract           no
  Autowired          no
  Autowiring Types   -
 ------------------ ------------------------------------    

我想这是正确的服务,我必须对其进行配置以在实际的ApcCache-Class上使用ApcuCache-Class.

i guess this is the right service which i have to configure to use the ApcuCache-Class over the actual ApcCache-Class.

非常感谢大家的帮助.

推荐答案

... ... ...

... ... ...

有可能仅覆盖实际服务...

its possible to just override the actual service ...

@/src/App/Bundle/Resources/config/services.yml:

@/src/App/Bundle/Resources/config/services.yml :

doctrine_cache.providers.apc_cache:
        class: Doctrine\Common\Cache\ApcuCache

好吧..第一次symfony/教义/...学习困难的方法...

well.. first time symfony/doctrine/... learning the hard way...

任何进一步的解释仍然令人赞赏.

any further explanation is still much appreciated.

有一个不错的人.

这篇关于如何在Symfony,Doctrine ORM和DoctrineCacheBundle中使用ApcuCache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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