jeudi 23 février 2017

laravel memory limit on two level relationship query with cache

Hoping someone can offer some advice.

I have this query:

Branch::with('users.books')->orderBy('name','asc')->get();

But when trying to cache it I'm getting:

Out of memory (allocated 961019904) (tried to allocate 441764623 bytes)

So it's not actually using all the memory it's allocated anyway - To cache it i'm simply:

$branches = Cache::remember('branches-reports', 1440, function() {
        return Branch::with('users.books')->orderBy('name','asc')->get();
});

I'm not sure how I can get around this.

Relationship wise a user can have one branch and a branch can have many users. Then the relationship between the books and users is a many to many using a pivot table.

any ideas?

Thanks.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2mfuIWo
via IFTTT

Aucun commentaire:

Enregistrer un commentaire