Files
newznab-tmux/app/Support/Database/Builder.php
T

35 lines
828 B
PHP

<?php
namespace App\Support\Database;
use Illuminate\Support\Facades\Cache;
use Illuminate\Database\Query\Builder as QueryBuilder;
class Builder extends QueryBuilder
{
/**
* Taken from https://laracasts.com/discuss/channels/guides/never-execute-a-duplicate-query-again
*
* Run the query as a "select" statement against the connection.
*
* @return array
*/
protected function runSelect()
{
return Cache::store('request')->remember($this->getCacheKey(), 1, function() {
return parent::runSelect();
});
}
/**
* Returns a Unique String that can identify this Query.
*
* @return string
*/
protected function getCacheKey()
{
return json_encode([
$this->toSql() => $this->getBindings()
]);
}
}