Re: Cache::delete() very slow

2009-06-12 Thread brian

On Fri, Jun 12, 2009 at 2:45 AM, AD7six wrote:
>
>
>
> On Jun 12, 6:07 am, brian  wrote:
>> I have a function which reorders a tree list using TreeBehavior's
>> moveup()/movedown(). This list is, more or less, a set of navigation
>> links. I'm using ACL so that I can display a slightly different
>> version for each of several (5-10) groups. To avoid having to make an
>> ACL lookup every page view, the trees are cached. So, any time a node
>> is edited/added/deleted/moved, I remove the cached trees. This is
>> generally ok as these actions will be performed only sporadically and
>> always by an admin.
>>
>> To move nodes around, I'm using some jquery drag & drop and then
>> sending an AJAX request. The method that handles the move includes a
>> call to __removeGroupSections() (shown below). I'm consistently seeing
>> this request take ~20 seconds. If I comment out the call to
>> __removeGroupSections() the request comes back in ~1 second.
>>
>> So, can anyone suggest a faster way to accomplish this?
>
> I'd suggest xdebug -> profile -> see where your 20s are going.

I'll check out using xdebug. It's certainly fine when I comment out
the Cache::delete()

> Why don't you put all your acl in a single folder (e.g. tmp/cache/
> acl/, create a new cache config to encompass it) then you can bulk
> delete them. (e.g exec('rm -rf tmp/cache/acl/*') ) or some other such
> planning for deletinging some/all strategy.

Bulk deleting works. Thanks for the tip.

The weird thing is that I've just discovered that there's some other
problem on the staging server. There's an error with this line:

$aros = $this->Acl->Aro->find('all');

I can't figure out how to debug this. Processing stops right there.

In any case, your alternative cache config idea works for now, so
there's no need for the find() call. In the meantime, I'm going to see
about installing memcached.

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



Re: Cache::delete() very slow

2009-06-11 Thread AD7six



On Jun 12, 6:07 am, brian  wrote:
> I have a function which reorders a tree list using TreeBehavior's
> moveup()/movedown(). This list is, more or less, a set of navigation
> links. I'm using ACL so that I can display a slightly different
> version for each of several (5-10) groups. To avoid having to make an
> ACL lookup every page view, the trees are cached. So, any time a node
> is edited/added/deleted/moved, I remove the cached trees. This is
> generally ok as these actions will be performed only sporadically and
> always by an admin.
>
> To move nodes around, I'm using some jquery drag & drop and then
> sending an AJAX request. The method that handles the move includes a
> call to __removeGroupSections() (shown below). I'm consistently seeing
> this request take ~20 seconds. If I comment out the call to
> __removeGroupSections() the request comes back in ~1 second.
>
> So, can anyone suggest a faster way to accomplish this?

I'd suggest xdebug -> profile -> see where your 20s are going.
>
> Here's the config I'm using--basic file cache. I'm sure the other
> suggestions in core.php would all be much more efficient but I don't
> really know much about them. Aside from any suggestions for improving
> use of file cache, I'd appreciate any comments about the differences
> between APC, XCache, and memcached. Especially as may pertain to Cake.
> I'm definitely interested in learning something about all of this.
>
> Cache::config(
>         'default', array(
>                 'engine' => 'File',
>                 'duration'=> 3600,
>                 'probability'=> 100,
>                 'path' => CACHE,
>                 'prefix' => 'cake_',
>                 'lock' => false,
>                 'serialize' => true
>         )
> );
>
> private function __removeGroupSections($aros = array())
> {
>         if (empty($aros))
>         {
>                 $aros = $this->Acl->Aro->find('all');
>         }
>
>         foreach ($aros as $aro)
>         {
>                 
> Cache::delete("sections_for_group_{$aro['Aro']['foreign_key']}");
>         }
>
> }
>
> And it's not due to the ARO lookup. I hard-coded the IDs into the
> method with the same slow result:
>
> private function __removeGroupSections($aros = array())
> {
>         $ids = array(1,2,3,4,5,6);
>
>         foreach ($ids as $id)
>         {
>                 Cache::delete("sections_for_group_{$id}");
>         }
>
> }
Why don't you put all your acl in a single folder (e.g. tmp/cache/
acl/, create a new cache config to encompass it) then you can bulk
delete them. (e.g exec('rm -rf tmp/cache/acl/*') ) or some other such
planning for deletinging some/all strategy.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Cache::delete() very slow

2009-06-11 Thread brian

I have a function which reorders a tree list using TreeBehavior's
moveup()/movedown(). This list is, more or less, a set of navigation
links. I'm using ACL so that I can display a slightly different
version for each of several (5-10) groups. To avoid having to make an
ACL lookup every page view, the trees are cached. So, any time a node
is edited/added/deleted/moved, I remove the cached trees. This is
generally ok as these actions will be performed only sporadically and
always by an admin.

To move nodes around, I'm using some jquery drag & drop and then
sending an AJAX request. The method that handles the move includes a
call to __removeGroupSections() (shown below). I'm consistently seeing
this request take ~20 seconds. If I comment out the call to
__removeGroupSections() the request comes back in ~1 second.

So, can anyone suggest a faster way to accomplish this?

Here's the config I'm using--basic file cache. I'm sure the other
suggestions in core.php would all be much more efficient but I don't
really know much about them. Aside from any suggestions for improving
use of file cache, I'd appreciate any comments about the differences
between APC, XCache, and memcached. Especially as may pertain to Cake.
I'm definitely interested in learning something about all of this.

Cache::config(
'default', array(
'engine' => 'File',
'duration'=> 3600,
'probability'=> 100,
'path' => CACHE,
'prefix' => 'cake_',
'lock' => false,
'serialize' => true
)
);

private function __removeGroupSections($aros = array())
{
if (empty($aros))
{
$aros = $this->Acl->Aro->find('all');
}

foreach ($aros as $aro)
{

Cache::delete("sections_for_group_{$aro['Aro']['foreign_key']}");
}
}


And it's not due to the ARO lookup. I hard-coded the IDs into the
method with the same slow result:

private function __removeGroupSections($aros = array())
{
$ids = array(1,2,3,4,5,6);

foreach ($ids as $id)
{
Cache::delete("sections_for_group_{$id}");
}
}

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