Re: Cache Help

2013-08-01 Thread Reuben
Oh, nice. My original reply was deleted.

Anyhoo, I might suggest that you only clear the cache for the particular 
Form(s) that were deleted or saved, using Cache::delete('getFormsById' . 
$id).  Although you may need to double check the event of multiple Forms 
being saved or deleted.  I think afterSave() and afterDelete() gets called 
for each entry, but you may want to check, just in case.

Regards
Reuben Helms

On Friday, 2 August 2013 01:48:26 UTC+10, Eric Haskins wrote:
>
> Here is one of my models for dynamic forms. I hope it helps this is 
> CakePHP 2.x  so I clear cache afterSave (editing a forms structure) or 
> afterDelete (selfexplanatory)  
>
> class Forms extends AppModel {
> public $primaryKey = 'id';
> 
> public function afterSave($created) {
> parent::afterSave($created);
> Cache::clear();
> clearCache();
> }
>
> public function  afterDelete() {
> parent::afterDelete();
> Cache::clear();
> clearCache();
> }
> 
> public function getFormsById($id){
> if (($form = Cache::read('getFormsById'.$id)) === false) {
> $form = $this->find('first', array('conditions' => 
> array('Forms.id'=>$id,'Forms.site_id'=> 
>  Configure::read('Settings.site_id';
> Cache::write('getFormsById'.$id, $form);
> }
> return $form;
> }
> }
>
> Hope this helps.  I am new to Cake cache so if I am wrong someone please 
> feel free to point it out
>
> Eric Haskins
> High Octane Brands LLC
> "Building Brands Not Just Business"
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Cache Help

2013-08-01 Thread Eric Haskins
Here is one of my models for dynamic forms. I hope it helps this is CakePHP 
2.x  so I clear cache afterSave (editing a forms structure) or afterDelete 
(selfexplanatory)  

class Forms extends AppModel {
public $primaryKey = 'id';

public function afterSave($created) {
parent::afterSave($created);
Cache::clear();
clearCache();
}

public function  afterDelete() {
parent::afterDelete();
Cache::clear();
clearCache();
}

public function getFormsById($id){
if (($form = Cache::read('getFormsById'.$id)) === false) {
$form = $this->find('first', array('conditions' => 
array('Forms.id'=>$id,'Forms.site_id'=> 
 Configure::read('Settings.site_id';
Cache::write('getFormsById'.$id, $form);
}
return $form;
}
}

Hope this helps.  I am new to Cake cache so if I am wrong someone please 
feel free to point it out

Eric Haskins
High Octane Brands LLC
"Building Brands Not Just Business"

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Cache Help

2013-07-29 Thread jmn2k1
You must "invalidate" the cache, ie, delete the cache in a onSave callback.

On Friday, July 26, 2013 9:05:30 PM UTC-3, advantage+ wrote:
>
> Maybe I was reading wrong but I was under the impression if you cache an 
> object (find data) if it was different it would delete the original cached 
> data.
>
>  
>
> I am caching the results of a find, but as admin if I edit the record the 
> cached data is always returned not the new data.
>
>  
>
> Is ther a way to fetch new data after save and delete cached info?
>
>  
>
> *Dave Maharaj*
>
> *Freelance Designer | Developer*
> [image: Description: header_logo]
> www.movepixels.com  |  d...@movepixels.com   |  709.800.0852
>
>  
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Cache Help

2013-07-28 Thread Reuben
I must admit, I've never cached model data. I figure the database engine 
will be better at caching data for quick (and often) retrieval in its 
buffers.  But I have done caching of results of web services, and the 
occasional view.

If you had to do caching of model data, then I would recommend clearing the 
relevant caches in the afterSave() and afterDelete() methods.  And even 
then, you should only need to clear the entry for the specific cached 
record.  You just need to make sure you an reproduce the key that you're 
using to save the data from the afterSave and afterDelete locations.

Regards
Reuben Helms

On Saturday, 27 July 2013 10:05:30 UTC+10, advantage+ wrote:
>
> Maybe I was reading wrong but I was under the impression if you cache an 
> object (find data) if it was different it would delete the original cached 
> data.
>
>  
>
> I am caching the results of a find, but as admin if I edit the record the 
> cached data is always returned not the new data.
>
>  
>
> Is ther a way to fetch new data after save and delete cached info?
>
>  
>
> *Dave Maharaj*
>
> *Freelance Designer | Developer*
> [image: Description: header_logo]
> www.movepixels.com  |  d...@movepixels.com   |  709.800.0852
>
>  
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Cache help

2010-02-15 Thread John Andersen
Ok, based on your code example, the list of offending words are in
your variable $restrictions, which is the same as a list from the
model. So you should be able to use something like:
[code]
if ( in_array($restrictions, 'my bad word') ) {
   // do something with bad word
}
[/code]

This could all be done by a model method, which ensures that the
latest restrictions are read from either the cache or the database,
then checks the word and returns whatever result you want.
Enjoy,
   John

On Feb 14, 9:51 pm, "Dave"  wrote:
> Right I know how to read cache if nothing then do the find and cache the
> data results. But in this case I want to search the cached data rather than
> look for a value in the db directly.
>
> Restrictions is a list of bad words. So I have my full list in the cache
> since it rarely changes. So if a user signs up with name "shitface" rather
> than search the entire db of words I figured it would be esier to see if its
> in the cached data. That’s where im stuck. Instead of find(model) im
> searching thru the cached data for name => shitface.
>
> Thanks,
>
> Dave
>
> -Original Message-
> From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
>
> Of John Andersen
> Sent: February-14-10 4:06 PM
> To: CakePHP
> Subject: Re: Cache help
>
> Use the code construction as defined in the CakePHP book 
> at:http://book.cakephp.org/view/767/Cache-write
> where the code first ask for the data from the cache and upon a false
> result, requests the data from the model, and fills the cache with the
> models result.
> Hope this helps you on the way,
>    John
>
> On Feb 13, 10:01 pm, "Dave"  wrote:
> > I want to add this in my User model for registrations checking for
> > banned words type thing.
>
> >   $params = array(
> >    'contain' => false,
> >    'fields' => array(
> >     'Restriction.id',
> >     'Restriction.name'));
>
> >   $restrictions = Cache::read('restrictions_cache', 'long');
>
> >   if (empty($restrictions))
> >   {
> >    Controller::loadModel('Restriction');
> >    $restrictions = $this->Restriction->find('list' , $params);
> >    Cache::write('restrictions_cache', $restrictions,'long');
> >   }
>
> > But how do I search the cache for data?
>
> > Right now I  have this to check the table but since the data in
> > Restrictions never changes I just want to cache the data and do my
> > find with the cached data.
>
> > $q = $this->Restriction->find('first' , array('conditions' => array(
> > 'Restriction.name LIKE' => $value)));
>
> > Thanks
>
> > Dave
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
> with their CakePHP related questions.
>
> 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
> cake-php+athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 help

2010-02-14 Thread Dave
Right I know how to read cache if nothing then do the find and cache the
data results. But in this case I want to search the cached data rather than
look for a value in the db directly.

Restrictions is a list of bad words. So I have my full list in the cache
since it rarely changes. So if a user signs up with name "shitface" rather
than search the entire db of words I figured it would be esier to see if its
in the cached data. That’s where im stuck. Instead of find(model) im
searching thru the cached data for name => shitface.

Thanks,

Dave

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of John Andersen
Sent: February-14-10 4:06 PM
To: CakePHP
Subject: Re: Cache help

Use the code construction as defined in the CakePHP book at:
http://book.cakephp.org/view/767/Cache-write
where the code first ask for the data from the cache and upon a false
result, requests the data from the model, and fills the cache with the
models result.
Hope this helps you on the way,
   John

On Feb 13, 10:01 pm, "Dave"  wrote:
> I want to add this in my User model for registrations checking for 
> banned words type thing.
>
>   $params = array(
>    'contain' => false,
>    'fields' => array(
>     'Restriction.id',
>     'Restriction.name'));
>
>   $restrictions = Cache::read('restrictions_cache', 'long');
>
>   if (empty($restrictions))
>   {
>    Controller::loadModel('Restriction');
>    $restrictions = $this->Restriction->find('list' , $params);
>    Cache::write('restrictions_cache', $restrictions,'long');
>   }
>
> But how do I search the cache for data?
>
> Right now I  have this to check the table but since the data in 
> Restrictions never changes I just want to cache the data and do my 
> find with the cached data.
>
> $q = $this->Restriction->find('first' , array('conditions' => array( 
> 'Restriction.name LIKE' => $value)));
>
> Thanks
>
> Dave

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.

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 
cake-php+at http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 help

2010-02-14 Thread John Andersen
Use the code construction as defined in the CakePHP book at:
http://book.cakephp.org/view/767/Cache-write
where the code first ask for the data from the cache and upon a false
result, requests the data from the model, and fills the cache with the
models result.
Hope this helps you on the way,
   John

On Feb 13, 10:01 pm, "Dave"  wrote:
> I want to add this in my User model for registrations checking for banned
> words type thing.
>
>   $params = array(
>    'contain' => false,
>    'fields' => array(
>     'Restriction.id',
>     'Restriction.name'));
>
>   $restrictions = Cache::read('restrictions_cache', 'long');
>
>   if (empty($restrictions))
>   {
>    Controller::loadModel('Restriction');
>    $restrictions = $this->Restriction->find('list' , $params);
>    Cache::write('restrictions_cache', $restrictions,'long');
>   }
>
> But how do I search the cache for data?
>
> Right now I  have this to check the table but since the data in Restrictions
> never changes I just want to cache the data and do my find with the cached
> data.
>
> $q = $this->Restriction->find('first' , array('conditions' => array(
> 'Restriction.name LIKE' => $value)));
>
> Thanks
>
> Dave

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 Help

2009-12-15 Thread Piotr Kilczuk
Hello,

> How do i make sure that the browser does not cache elements, pages. I have
> the cache no cache blocks in view, cache helper in app_controller, var
> cacheAction = false. tried everything but nothing seems to work.

How about http://api.cakephp.org/class/controller#method-ControllerdisableCache
?

Regards,
Piotr

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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 Help

2009-11-02 Thread Dave

Maybe I should have put in baby steps for you to follow.
1. Click edit
2.Save
3. Save redirects you back to index.
4.Look no new content
5.Click new or edit
6.Save
7.Back to index
8.No new content , add or edit new content and nothing shows up until you
hit refresh...(the index is cached)i know on other sites on the web when you
save or edit your content you don’t have to refresh the page to see your
updatesmaybe the sites I go to are different than the ones you do but im
sure if you thought about it you might see what I mean?
9.Hit refresh
10.WOW LOOK new content

Yes $this->cacheAction = false;

If you don’t have ananswer your can keep your snarky additude response's to
your self "You have to hit refresh to reload a webpage... like everyone
else?" Yes because that exactly what I was asking!

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of Robert P
Sent: November-02-09 11:30 PM
To: CakePHP
Subject: Re: Cache Help


OK, this one confused me. You have to hit refresh to reload a webpage...
like everyone else?

And I've never seen $this->disableCache() before. Since 1.1 I've been using
$this->cacheAction = false;

On Nov 3, 8:48 am, "Dave"  wrote:
> I need some help figuring out caching. A lot of the site I am working 
> on is dynamic and I do not want to cache the constantly changing data /
actions.
>
> I have added Cache to app_controller, even to individual controllers,
>
> added nocache blocks in the views, $this->disableCache(); in 
> controllers
>
> but everytime i make a change i have to hit refresh to get the new 
> data. not just on one page but every page
>
> Any tips, suggestion?
>
> Dave


--~--~-~--~~~---~--~~
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 Help

2009-11-02 Thread Robert P

OK, this one confused me. You have to hit refresh to reload a
webpage... like everyone else?

And I've never seen $this->disableCache() before. Since 1.1 I've been
using $this->cacheAction = false;

On Nov 3, 8:48 am, "Dave"  wrote:
> I need some help figuring out caching. A lot of the site I am working on is
> dynamic and I do not want to cache the constantly changing data / actions.
>
> I have added Cache to app_controller, even to individual controllers,
>
> added nocache blocks in the views, $this->disableCache(); in controllers
>
> but everytime i make a change i have to hit refresh to get the new data. not
> just on one page but every page
>
> Any tips, suggestion?
>
> Dave
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---