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: [email protected] [mailto:[email protected]] 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" <[email protected]> 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 [email protected] To unsubscribe from this group, send email to [email protected] 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
