mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 09:18:54 +00:00
87c6e5d64f
[ci skip] [skip ci]
36 lines
832 B
PHP
36 lines
832 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(),
|
|
]);
|
|
}
|
|
}
|