Development

#3141 ([PATCH] View cache doesn't accept zero client lifetime)

You must first sign up to be able to contribute.

Ticket #3141 (closed defect: fixed)

Opened 9 months ago

Last modified 9 months ago

[PATCH] View cache doesn't accept zero client lifetime

Reported by: francois Assigned to: fabien
Priority: minor Milestone: 1.0.12
Component: cache Version: 1.0.10
Keywords: Cc:
Qualification: Unreviewed

Description

The sfViewCacheManager::addCache() method allows to define a server side cache lifetime (used by symfony) and a client side cache lifetime (used by proxies and browsers).

For a specific use, I want a server-side lifetime of 10 seconds, but a client-side lifetime of 0. So I just register my cache as follows:

$viewCacheManager->addCache('mymodule', 'myction', array(
  'withLayout' => true,
  'lifeTime' => 10,
  'clientLifeTime' => 0,
  'contextual' => false,
  'vary' => array ()
));

The problem is that line 172 of the sfViewCacheManager, the addCache() method just ignores the client lifetime if it is equal to zero:

    $this->cacheConfig[$moduleName][$actionName] = array(
      'withLayout'     => isset($options['withLayout']) ? $options['withLayout'] : false,
      'lifeTime'       => $options['lifeTime'],
      'clientLifeTime' => isset($options['clientLifeTime']) ? $options['clientLifeTime'] : $options['lifeTime'],
      'contextual'     => isset($options['contextual']) ? $options['contextual'] : false,
      'vary'           => isset($options['vary']) ? $options['vary'] : array(),
    );

So I end up with a cache configuration of 10s lifetime for both the server side and the client side, which is not what I want.

Attached is a simple patch to fix this.

Attachments

sfViewCacheManager.patch (0.9 kB) - added by francois on 03/17/08 14:48:47.
sfCacheFilter.patch (1.1 kB) - added by francois on 03/17/08 15:09:18.

Change History

03/17/08 14:48:47 changed by francois

  • attachment sfViewCacheManager.patch added.

03/17/08 15:09:05 changed by francois

Also, I think that sfCacheFilter lacks a nice

if($lifetime)

on line 122, ending line 125 (attaching second patch).

03/17/08 15:09:18 changed by francois

  • attachment sfCacheFilter.patch added.

03/19/08 17:35:54 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.

(In [7976]) fixed view cache doesn't accept zero client lifetime (closes #3141)

03/19/08 17:37:26 changed by fabien

  • milestone set to 1.0.12.

in r7977