Note that there are some explanatory texts on larger screens.

plurals
  1. POLaravel 4 Query Cache
    primarykey
    data
    text
    <p>I'm having trouble getting my queries to cache. Anytime I hit my API I am getting fresh results from the DB instead of the Cached results that im going for. The odd thing is if I look in the file cache I can see the cached results and they are exactly what im expecting, yet when I call the API I get fresh results. Below are some snippets of the relevant files. Where am I going wrong here?</p> <p>Repository Function my API calls:</p> <pre><code>public function topMonth() { $top = $this-&gt;repository-&gt;month()-&gt;top()-&gt;joinUser()-&gt;remember(30)-&gt;get(['things.id', 'things.votes', 'things.title', 'things.description', 'things.tags', 'things.created_at', 'users.id as user_id','users.username','users.picture as user_picture'])-&gt;toArray(); return $top; } </code></pre> <p>Model</p> <pre><code>class Thing extends Eloquent { public function scopeTop($query) { return $query-&gt;orderBy('things.votes', 'desc'); } public function scopeYear($query) { return $query-&gt;whereRaw("things.created_at &gt; STR_TO_DATE('" . Carbon::now()-&gt;subYear() . "', '%Y-%m-%d %H:%i:%s')"); } public function scopeMonth($query) { return $query-&gt;whereRaw("things.created_at &gt; STR_TO_DATE('" . Carbon::now()-&gt;subMonth() . "', '%Y-%m-%d %H:%i:%s')"); } public function scopeWeek($query) { return $query-&gt;whereRaw("things.created_at &gt; STR_TO_DATE('" . Carbon::now()-&gt;subWeek() . "', '%Y-%m-%d %H:%i:%s')"); } public function scopeDay($query) { return $query-&gt;whereRaw("things.created_at &gt; STR_TO_DATE('" . Carbon::now()-&gt;subDay() . "', '%Y-%m-%d %H:%i:%s')"); } public function scopeJoinUser($query) { return $query-&gt;join('users', function($join) { $join-&gt;on('users.id', '=', 'things.created_by'); }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload