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

How much data can the session cache array (sensibly) hold?

Development and Programming

iain's avatar
iain
317 posts
about 15 years ago
iain's avatar iain

Hiya,

I’m working on Taxonomy 2.x at the moment and I’ve made the decision to store tree arrays much like the pages module does and load each tree into the current user’s session via the sessions_end extension hook.

My concern is that tree data is a lot heavier than just entry_id => template / entry_id => url

Here’s an array of a very simple tree with 3 nodes for example:

[taxonomy] => Array
        (
            [tree] => Array
                (
                    [1] => Array
                        (
                            [label] => About Us
                            [tree_array] => Array
                                (
                                    [0] => Array
                                        (
                                            [node_id] => 1
                                            [lft] => 1
                                            [rgt] => 6
                                            [label] => Home
                                            [entry_id] => 32
                                            [template_path] => 0
                                            [custom_url] => [page_uri]
                                            [field_data] => 
                                            [status] => open
                                            [highlight] => 009933
                                            [channel_id] => 1
                                            [title] => Home
                                            [url_title] => home
                                            [entry_date] => 1303983262
                                            [template_id] => 
                                            [group_id] => 
                                            [template_name] => 
                                            [group_name] => 
                                            [is_site_default] => 
                                            [level] => 0
                                            [has_children] => yes
                                            [children] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [node_id] => 4
                                                            [lft] => 2
                                                            [rgt] => 3
                                                            [label] => Here's a page
                                                            [entry_id] => 81
                                                            [template_path] => 
                                                            [custom_url] => [page_uri]
                                                            [field_data] => 
                                                            [status] => open
                                                            [highlight] => 009933
                                                            [channel_id] => 1
                                                            [title] => Here's the about page
                                                            [url_title] => heres_the_about_page
                                                            [entry_date] => 1304564140
                                                            [template_id] => 
                                                            [group_id] => 
                                                            [template_name] => 
                                                            [group_name] => 
                                                            [is_site_default] => 
                                                            [level] => 1
                                                        )

                                                    [1] => Array
                                                        (
                                                            [node_id] => 5
                                                            [lft] => 4
                                                            [rgt] => 5
                                                            [label] => Here's another page
                                                            [entry_id] => 82
                                                            [template_path] => 
                                                            [custom_url] => [page_uri]
                                                            [field_data] => 
                                                            [status] => open
                                                            [highlight] => 009933
                                                            [channel_id] => 1
                                                            [title] => Here's the contact page
                                                            [url_title] => heres_the_contact_page
                                                            [entry_date] => 1304564185
                                                            [template_id] => 
                                                            [group_id] => 
                                                            [template_name] => 
                                                            [group_name] => 
                                                            [is_site_default] => 
                                                            [level] => 1
                                                        )

                                                )

                                        )

                                )

                        )

                )

        )

Is this just stoopid? Should I not bother with this plan?

       
iain's avatar
iain
317 posts
about 15 years ago
iain's avatar iain

I should mention that I’m not doing huge queries to generate this data, when a tree is edited for example, this tree array is stored as a base64encoded serialized array which means all trees are grabbed on page load with one very quick query.

       
iain's avatar
iain
317 posts
about 15 years ago
iain's avatar iain

OK, I’ve done some testing on this based on feedback on Twitter from @gaker and @_rsan:

So loading EE out of the box, Taxonomy not enabled and just rendering a blank template:

MEMORY USAGE                 861,300 bytes
Loading Time: Base Classes      0.0009
Controller Execution Time      0.0096
Total Execution Time            0.0107

Enabling Taxonomy with the extension base64decoding and unserializing two trees into the user’s session array, (400 nodes and 200 nodes) + rendering a tree as an unordered list with 400 nodes using the exp:taxonomy:nav tag:

MEMORY USAGE                 2,606,536 bytes
Loading Time: Base Classes      0.0010
Controller Execution Time      0.1059
Total Execution Time            0.1070

Does this raise any eyebrows?

       
Rob Sanchez's avatar
Rob Sanchez
335 posts
about 15 years ago
Rob Sanchez's avatar Rob Sanchez

That’s totally acceptable memory usage in my book.

       
iain's avatar
iain
317 posts
about 15 years ago
iain's avatar iain

Thanks Rob, really appreciate you looking at this for me.

       
Greg Ferrell's avatar
Greg Ferrell
102 posts
14 years ago
Greg Ferrell's avatar Greg Ferrell

I agree with Rob here that the mem usage isn’t bad, however by loading it in sessions, you are loading it all the time even if the template doesn’t require it.

Why not just parse it when the first tag is called and cache it for subsequent calls?

       
jwindhorst's avatar
jwindhorst
99 posts
14 years ago
jwindhorst's avatar jwindhorst

This is slightly off topic, but since you said you were working on Taxonomy 2.x I was wondering if you might consider a new feature that we are in need of. We have non technical editors (which is likely a common situation) and we are using Taxonomy for our navigation and general hierarchy. The issue becomes if our editors drag too many nodes to the root level, it would eventually break the design of the site. The feature request would be to have the ability to “lock down” certain node levels based on user groups to prevent this from happening.

Great job on Taxonomy BTW, I can tell you how many hours it has saved us already!

       

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.