标签: zend-cache

Zend OPCache - opcache.enable_cli 1还是0?它有什么作用?

在文档中,它说"主要用于调试",这会让我觉得"除非你遇到问题并且需要做一些调试,否则永远不会启用它",但是阅读大部分我能找到的关于它的内容都说"启用它"opcache .enable_cli 1"但为什么?我找不到有关此事的任何信息,所以如果有人知道,如果文档基本上说保持0,我为什么要启用它?

php zend-cache opcache php-5.5

28
推荐指数
2
解决办法
2万
查看次数

清除Zend Cache的模式

我开始使用Zend Cache(APC后端),并且在返回缓存值方面都很好,而不是每次都访问数据库.但是,继承人我的问题:

$cache_key = 'getrebates_'.$operator_code;

if(PP_Model_CacheService::exists($cache_key)) {
    $cached_values = PP_Model_CacheService::load($cache_key);
} else {
   //hits the db    
   $cached_values = $this->getAll($operator_code);
   PP_Model_CacheService::save($cached_values, $cache_key);
}
return $cached_values;
Run Code Online (Sandbox Code Playgroud)

每个运营商都有自己的折扣,这些折扣因运营商而异,现在如果我更改数据库并需要清除所有运营商的折扣,我该怎么做?

我可以使用$ Cache-> clean(),但这将清除其他缓存(不仅仅是每个运算符的rebate缓存).如果我循环遍历所有运算符:

foreach($operator_codes AS $operator_code) {
   $cache_key = 'getrebates_'.$operator_code;
   $cache->delete($cache_key)
}
Run Code Online (Sandbox Code Playgroud)

这看起来像缓存的很多工作.有没有办法清除一部分缓存.

//Something like:
$section_key = 'getrebates';
$Cache[$section_key][$operator_code];
$Cache->clearSection($section_key);
Run Code Online (Sandbox Code Playgroud)

APC缓存是否有任何数组结构,还是基于缓存键/值?

zend-framework zend-cache

6
推荐指数
1
解决办法
6160
查看次数

Zend Config Ini缓存

我的Zend应用程序使用3个ini配置文件,总共超过200行进行解析,包含100多条指令.每个请求都解析这些文件吗?有人说他们(就像这里这里一样).如果是这样,这不是效率问题吗?

这些链接中的评论含糊不清 - 有人说你应该避免ini配置文件并在PHP中进行配置,有人说你可以使用Zend_Cache_Frontend_File,有些人说这不是问题.但是,如果您预计会有相当多的流量,那么为每个请求分析200行文本肯定会很快成为问题吗?

如果您的确建议使用缓存技术,请详细说明如何实现缓存技术?

php zend-framework zend-cache zend-config

4
推荐指数
1
解决办法
8752
查看次数

如何设置Zend Cache Storage的到期时间?

我想将一些XML存储在Zend文件系统缓存中,并在30分钟后过期.如何设置缓存持续时间/到期?我使用Zend缓存作为组件,而不是在完整的ZF2应用程序的上下文中.

$cache   = \Zend\Cache\StorageFactory::factory(array(
    'adapter' => array(
        'name' => 'filesystem',
        'ttl' => 60, // kept short during testing
        'options' => array('cache_dir' => __DIR__.'/cache'),
    ),
    'plugins' => array(
        // Don't throw exceptions on cache errors
        'exception_handler' => array(
            'throw_exceptions' => false
        ),
    )
));
$key    = 'spektrix-events';   
$events = new SimpleXMLELement($cache->getItem($key, $success));

if (!$success) {
    $response = $client->setMethod('GET')->send();
    $events = new SimpleXMLElement($response->getContent());
    $cache->setItem('spektrix-events', $events->asXML());
}


var_dump($cache->getMetadata($key)); // the mtime on the file stays the same as does timestamp from ls -al …
Run Code Online (Sandbox Code Playgroud)

php zend-cache zend-framework2

4
推荐指数
1
解决办法
6096
查看次数

奇怪的行为序列化对象和缓存它们

我遇到了一个似乎无法缩小范围的问题.在Zend Framework应用程序中,我使用Zend Cache来缓存自定义Response对象中包含的潮汐和天气数据.最初创建数据的点,一切正常.我序列化并缓存它.然后,当我点击刷新并从缓存中提取数据时,我收到以下错误:

消息:无法将字符串解析为XML

堆栈跟踪:

0 /home/cillosis/mysites/tidely/application/views/scripts/tides/location.phtml(38):SimpleXMLElement - > __ construct('')

1 /home/cillosis/mysites/tidely/library/Zend/View.php(108):include('/ home/cillosis/...')

2 /home/cillosis/mysites/tidely/library/Zend/View/Abstract.php(888):Zend_View - > _ run('/ home/cillosis/...')

...

这发生在我的视图中,我访问自定义"响应对象"中包含的XML,其中包含:

<div class="data-box">

<h3>Current Weather</h3>
<hr>
<?php

// *** THIS IS LINE 38  ***                         
$weather_XML = new SimpleXMLElement($this->response->_weatherdata->weatherResults);
$params = $weather_XML->data->parameters;

$img_path = $params->{'conditions-icon'}->{'icon-link'};

echo("<img src='".$img_path."'>");

...
Run Code Online (Sandbox Code Playgroud)

这是第一次运行时(缓存之前)对象的相关部分的转储:

["_weatherdata"]=>
  object(Tidely_WeatherData)#79 (6) {
    ["weatherResults"]=>
    string(6399) "<?xml version="1.0"?>
       <dwml version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="http://graphical.weather.gov/xml/DWMLgen/schema/DWML.xsd">
          ...
       </dwml> "
Run Code Online (Sandbox Code Playgroud)

你看到"......"的地方还有很多其他的XML数据.XML来自NWS(国家气象服务)API,我通过XML验证器运行它,它没有显示任何错误.一旦我序列化我的对象并缓存它就会发生问题.这是我如何设置Zend Cache:

// Setup caching
$frontendOptions = array('lifeTime' => 30, 'automatic_seralization' => …
Run Code Online (Sandbox Code Playgroud)

php serialization zend-framework zend-cache

3
推荐指数
1
解决办法
687
查看次数

缓存的最佳做法是什么?有什么限制?

我使用Zend_cache来缓存一些复杂的数据库查询,服务等的结果.

我的网站是社交网站,这意味着有很多用户互动.

我也可以在这里和那里缓存用户数据.但是,这意味着,我将拥有近万个缓存文件(拥有10 000个用户).这种方法是否缓存来自db的几乎所有内容仍然有利于性能?或者文件系统有一些限制?

正在寻找一些文章,没有找到.

谢谢你的建议!Jaroušek

php performance caching zend-cache

2
推荐指数
1
解决办法
397
查看次数

Zend Framework的后端与前端缓存之间有什么不同

我正在为使用Zend Framework的网站实现缓存.

我查看源代码并看到:

Zend_Cache::factory()
Run Code Online (Sandbox Code Playgroud)

总是需要后端和前端的两种配置.

我的问题是:

我不知道为什么后端设置在前端,
它们之间有什么区别?

$frontendObject->setBackend($backendObject);
return $frontendObject;
Run Code Online (Sandbox Code Playgroud)

这是原始的源代码:

public static function factory($frontend, $backend, $frontendOptions = array(), $backendOptions = array(), $customFrontendNaming = false, $customBackendNaming = false, $autoload = false)
{
    if (is_string($backend)) {
        $backendObject = self::_makeBackend($backend, $backendOptions, $customBackendNaming, $autoload);
    } else {
        if ((is_object($backend)) && (in_array('Zend_Cache_Backend_Interface', class_implements($backend)))) {
            $backendObject = $backend;
        } else {
            self::throwException('backend must be a backend name (string) or an object which implements Zend_Cache_Backend_Interface');
        }
    }
    if (is_string($frontend)) {
        $frontendObject = self::_makeFrontend($frontend, $frontendOptions, $customFrontendNaming, …
Run Code Online (Sandbox Code Playgroud)

zend-framework zend-cache

2
推荐指数
1
解决办法
3055
查看次数

如何向图像添加缓存控制过期标头?

我正在努力加速我网站上的活动.YSlow警告我,我的图片缺少过期标题.但是我如何在图像上应用这样的标题?

我的应用程序基于zend框架.图像存储在文件夹中的图像,我怎样才能为它们设置过期标题?

php zend-framework cache-control zend-cache

1
推荐指数
1
解决办法
2720
查看次数

使用md5()在Zend_Cache中生成缓存键

我在保存缓存对象的标识符时遇到了一些问题Zend_Cache.该Zend_Cache标识必须非常消毒(无特殊字符,不能有空格,等等).我的一些内部标识符中包含空格,因此保存缓存对象是一个问题.

我在考虑在保存之前使用md5()转换zend_cache标识符,例如:

$cacheId = md5(self::CACHE_PREFIX . $propertyId);

if (($address = $cache->load($cacheId)) === false) {
  .....
    $cache->save($cacheId, $address);
}
Run Code Online (Sandbox Code Playgroud)

(例如,$propertyId可能是带有空格的字符串)

我的问题是我创建的那些md5字符串有多独特?我的两个缓存对象是否可能具有相同的标识符?有什么建议?

php zend-framework zend-cache

0
推荐指数
1
解决办法
1364
查看次数

Zend Framework 2 - 最快的缓存适配器?

我的网站将严重依赖缓存,所以我应该选择Chache Adapter?文件系统肯定是最慢的,但其中哪一个是最快的?我可以控制我的php扩展,所以除了Zend Server之外,我可以让它们全部工作.所有这些适配器都有基准测试吗?

Apc Adapter,
Dba Adapter,
Memcached Adapter,
Memory Adapter,
WinCache Adapter
Run Code Online (Sandbox Code Playgroud)

zend-cache zend-framework2

0
推荐指数
1
解决办法
1222
查看次数