mybb / mybb2

The repository for the MyBB 2 forum software. Not to be used on live boards.
https://www.mybb.com
BSD 3-Clause "New" or "Revised" License
109 stars 45 forks source link

Cache relations #149

Open JN-Jones opened 9 years ago

JN-Jones commented 9 years ago

Laravel caches (as always) nothing, so the following code will run the same query three times:

$forum = Forum::find(1);

$forum->parent;
$forum->parent;
$forum->parent;

while the following code will do the same but run the query only once:

$forum = Forum::find(1);

Forum::find($forum->parent_id);
Forum::find($forum->parent_id);
Forum::find($forum->parent_id);
wpillar commented 9 years ago

Moving this to Beta 1 milestone, not essential for Alpha releases as it's an optimisation.