首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >xampp apache apc在symfony2中不起作用

xampp apache apc在symfony2中不起作用
EN

Stack Overflow用户
提问于 2015-07-31 05:20:56
回答 1查看 740关注 0票数 0

我有一个高TTFB (第一个字节的时间)的问题。

请建议如何安装APC或xcache。安装了opcache,但我不知道如何在Symfony2中使用。

代码语言:javascript
复制
rpandey@FIRST-PC /c/xampp/htdocs/ims
$ php -v
C:\xampp\php\ext\php_apc.dll doesn't appear to be a valid Zend extension
PHP 5.6.11 (cli) (built: Jul  9 2015 20:55:40)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies


In the php.ini I have,
[APC]
zend_extension = "C:\xampp\php\ext\php_apc.dll"
;specifies the size for each shared memory segment 8MB to start
apc.shm_size=8M
;max amount of memory a script can occupy
apc.max_file_size=1M
apc.ttl=0
apc.gc_ttl=3600
; means we are always atomically editing the files
apc.file_update_protection=0
apc.enabled=1
apc.enable_cli=1
apc.cache_by_default=1
apc.include_once_override=0
apc.localcache=0
apc.localcache.size=512
apc.num_files_hint=1000
apc.report_autofilter=0
apc.rfc1867=1
apc.slam_defense=0
apc.stat=1
apc.stat_ctime=0
apc.ttl=7200
apc.user_entries_hint=4096
apc.user_ttl=7200
apc.write_lock=1

在我的app/config/config_prod.yml中

我想同时做两个框架:

代码语言:javascript
复制
framework:
    validation:
        cache: validator.mapping.cache.apc
    serializer:
        cache: serializer.mapping.cache.apc

#doctrine:
#    orm:
#        metadata_cache_driver: apc
#        result_cache_driver: apc
#        query_cache_driver: apc

我现在已经评论了信条。以后会处理的。

在中,app.php:我要执行以下操作

代码语言:javascript
复制
$apcLoader = new ApcClassLoader(sha1(__FILE__), $loader);
$loader->unregister();
$apcLoader->register(true);
EN

回答 1

Stack Overflow用户

发布于 2015-07-31 15:16:03

这个问题通过同时使用opcache和APCu得到了解决。TTFB现在从6-10秒下降到100毫秒。感谢ficuscr的帮助。我还有另一个关于管理缓存的问题,我将在完成研究后发布一个单独的问题。

我当前的app.php如下所示

代码语言:javascript
复制
<?php

use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
//$loader = require_once __DIR__.'/../app/AppCache.php';

// Enable APC for autoloading to improve performance.
// You should change the ApcClassLoader first argument to a unique prefix
// in order to prevent cache key conflicts with other applications
// also using APC.

$loader = new ApcClassLoader('ims', $loader);
//$loader->unregister();
//$apcLoader->register(true);
$loader->register(true);

require_once __DIR__.'/../app/AppKernel.php';
require_once __DIR__.'/../app/AppCache.php';

$kernel = new AppKernel('prod', true);
$kernel->loadClassCache(); 
$kernel = new AppCache($kernel); //comment it

// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
//$response->setETag(md5($response->getContent()));
                $response->setPublic(); // make sure the response is public/cacheable
                //$response->isNotModified($request);
                $response->setMaxAge(400);
                $response->setSharedMaxAge(500);
$response->send();
$kernel->terminate($request, $response);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31734278

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档