gpt4 book ai didi

php - Doctrine 2 结果缓存

转载 作者:太空宇宙 更新时间:2023-11-03 10:59:30 26 4
gpt4 key购买 nike

我想像这样在 Zend Framework 2 项目上使用 Doctrine 2 的结果缓存:

$query->useResultCache(true, 3600, 'test');

但它不起作用。

这是我的配置文件:

<?php
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' =>'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'root',
'password' => '',
'dbname' => 'skeleton',
'charset' => 'utf8',
'driverOptions' => array (1002 => 'SET NAMES utf8'),
)
)
),
'configuration' => array(
'orm_default' => array(
'metadata_cache' => 'array',
'query_cache' => 'array',
'result_cache' => 'array',
'driver' => 'orm_default',
'generate_proxies' => true,
'proxy_dir' => 'data/DoctrineORMModule/Proxy',
'proxy_namespace' => 'DoctrineORMModule\Proxy',
'filters' => array()
)
),
)
);

那么我的问题是:我的代码中缺少什么?

最佳答案

您正在使用 ArrayCache 实现:

'result_cache'      => 'array',

ArrayCache 是一个“假”缓存,它只是将值放入一个数组中,该数组在请求结束时消失,就像 PHP 中的其他所有内容一样。您需要使用在请求之间保持事件状态的缓存,例如 APC、Memcache、XCache。我会给出有关如何执行此操作的指示,但我不熟悉 Zend2,请查看文档所说的内容,您可能只需要将上述行更改为“apc”即可。

关于php - Doctrine 2 结果缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17041995/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com