Re: [symfony-users] Re: Best way to get 2 cache versions : anonymous / authenticated users

2010-01-20 Thread Nicolas CHARLOT
Le 17 janv. 2010 à 22:45, Ali a écrit :

 I think it's better to override generateCacheKey function in
 ViewCacheManager.
 
 To do this you need to declare 'sf_cache_namespace_callable' config
 value and set it to your function name, which will alter the key
 depending on the user session parameters (you can get the initial key
 by calling original sfViewCacheManager instance from withing this
 function).

Ok.
But If I call generateCacheKey() of sfViewCacheManager within my callable it 
will be a infinite loop?

--
Nicolas CHARLOT




-- 
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.




Re: [symfony-users] Re: Best way to get 2 cache versions : anonymous / authenticated users

2010-01-20 Thread Nicolas CHARLOT
Le 20 janv. 2010 à 12:06, AlexT a écrit :

 Sure it will cycle, you must prevent that changing settings temporary.
 Kind of:
 
 
 $oldcallable = sfConfig::get('sf_cache_namespace_callable');
 sfConfig::set('sf_cache_namespace_callable', null); //disable cycling 
 call
 
 $key = $viewCacheManager-generateCacheKey($internalUri, $hostName, 
 $vary, $contextualPrefix); //old key
 
 // change key here
 
 sfConfig::set('sf_cache_namespace_callable', $oldcallable); //restore 
 callable

Ok.
So I think extending directly sfViewCacheManager is still smarter...

--
Nicolas CHARLOT




-- 
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.




[symfony-users] Re: Best way to get 2 cache versions : anonymous / authenticated users

2010-01-19 Thread Ali

I think it's better to override generateCacheKey function in
ViewCacheManager.

To do this you need to declare 'sf_cache_namespace_callable' config
value and set it to your function name, which will alter the key
depending on the user session parameters (you can get the initial key
by calling original sfViewCacheManager instance from withing this
function).


On 17 янв, 23:01, Nicolas CHARLOT nicolas.char...@gmail.com wrote:
 Hi,

 For this project I'm using Sf 1.2, but soon 1.4.

 I need to get 2 cache versions of a few actions (but not all):
 - 1 for anonymous users,
 - 1 for authenticated users.

 Do I have to write my own ViewCacheManager?

 Thanks.
 Nicolas CHARLOT
-- 
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.




[symfony-users] Re: Best way to get 2 cache versions : anonymous / authenticated users

2010-01-18 Thread Massimiliano Arione
On 18 Gen, 10:05, Nicolas CHARLOT nicolas.char...@gmail.com wrote:
 I need to store 2 versions of a same action depending on user status 
 (authenticated and member or not).

 The solution I founded was to write my own viewCacheManager:
 It works but all actions are cached twice and it's not necessary. I'm looking 
 for the best practice to do that.

 ?php

 class myViewCacheManager extends sfViewCacheManager
 {
   public function generateCacheKey($internalUri, $hostName = '', $vary = '', 
 $contextualPrefix = '')
   {
     $internalUri .= strpos($internalUri, '?') !== false ? 'member=' : 
 '?member=';
     $internalUri .= 
 sfContext::getInstance()-getUser()-canViewRestrictedMemberContent() ? '1' : 
 '0';

     return parent::generateCacheKey($internalUri, $hostName, $vary, 
 $contextualPrefix);
   }

 }

Nicholas, IMHO your solution is good.
I don't know any other solution for a such problem.
Why do you say that a double cache is not necessary? Indeed, it's
exactly what you need!
-- 
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.




[symfony-users] Re: Best way to get 2 cache versions : anonymous / authenticated users

2010-01-18 Thread ken
You can probably set up a filter to check for settings in cache.yml.
like add a boolean setting but you will also need to override
sfCacheConfigHandler to persist the setting into the cache.



On Jan 18, 8:57 pm, Massimiliano Arione garak...@gmail.com wrote:
 On 18 Gen, 10:05, Nicolas CHARLOT nicolas.char...@gmail.com wrote:





  I need to store 2 versions of a same action depending on user status 
  (authenticated and member or not).

  The solution I founded was to write my own viewCacheManager:
  It works but all actions are cached twice and it's not necessary. I'm 
  looking for the best practice to do that.

  ?php

  class myViewCacheManager extends sfViewCacheManager
  {
    public function generateCacheKey($internalUri, $hostName = '', $vary = 
  '', $contextualPrefix = '')
    {
      $internalUri .= strpos($internalUri, '?') !== false ? 'member=' : 
  '?member=';
      $internalUri .= 
  sfContext::getInstance()-getUser()-canViewRestrictedMemberContent() ? '1' 
  : '0';

      return parent::generateCacheKey($internalUri, $hostName, $vary, 
  $contextualPrefix);
    }

  }

 Nicholas, IMHO your solution is good.
 I don't know any other solution for a such problem.
 Why do you say that a double cache is not necessary? Indeed, it's
 exactly what you need!
-- 
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.




Re: [symfony-users] Re: Best way to get 2 cache versions : anonymous / authenticated users

2010-01-18 Thread Nicolas CHARLOT
Le 18 janv. 2010 à 13:57, Massimiliano Arione a écrit :

 Nicholas, IMHO your solution is good.
 I don't know any other solution for a such problem.
 Why do you say that a double cache is not necessary? Indeed, it's
 exactly what you need!

Most of my actions are identical for members and anonymous users. So handling 2 
versions of cache is useless in this case.-- 
You received this message because you are subscribed to the Google Groups 
symfony users group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.