We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

$this->EE->session->cache

Development and Programming

Bransin's avatar
Bransin
157 posts
15 years ago
Bransin's avatar Bransin

I’m fairly new with this and getting closer to releasing my first plugin. I’ve gone over the guidelines to make sure that everything is sound and secure. I’m having a hard time understanding the $this->EE->session->cache

http://ellislab.com/expressionengine/user-guide/development/guidelines/performance.html#redundant_queries

I understand why it’s important, but the syntax I don’t quite understand.

Find a way to run such queries only once, outside of loops, by perhaps accessing all of the information your add-on will require for each iteration, storing it in a master array.
if ( ! isset($this->EE->session->cache['super_class']['names'])) { $query = $this->EE->db->query('SELECT id, name FROM exp_pre_email_addresses WHERE id IN ('.implode(',', $ids).')'); if ($query->num_rows() > 0) { foreach ($query->result_array() as $row) { $this->EE->session->cache['super_class']['names'][$row['id']] = $row['name']; } } }

‘super_class’ key is chosen because of the class name? I’m confused by the element keys. My guess is that you’re looping through and defining this array with your own defined array with keys? What if it’s a query that selects multiple columns or if you’re only returning one result, is this necessary? i.e. pair tags, and using a single variable that returns the same result multiple times. Is it beneficial to use this? What I fail to understand is how to use this fully, and whether to use it when a single row from a query is returned.

“flash content” - is not sticking. Maybe with all these questions that have been running around in my brain for the past few days will be corrected by 1 answer that will give light to all questions. Right now my light bulb is dead and any help is appreciated.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.