Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.x' into 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Feb 16, 2022
2 parents 3a58a2f + 77c68df commit dcf7952
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/CacheAwareProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public function __construct(
protected bool $executingCallback = false,
protected ?Lock $lockInstance = null,
protected bool $bypassCacheCheck = false,
)
{
) {
// This callback interrupts the query execution on cache hit.
$this->queryBuilder->beforeQuery(function (): void {
// We will avoid looping this callback if it's executing.
Expand Down
6 changes: 3 additions & 3 deletions src/CacheQueryServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use Closure;
use DateInterval;
use DateTimeInterface;
use function func_get_args;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\ServiceProvider;
use function func_get_args;

/**
* @internal
Expand All @@ -35,11 +35,11 @@ public function register(): void
*/
public function boot(): void
{
if (!Builder::hasMacro('cache')) {
if (! Builder::hasMacro('cache')) {
Builder::macro('cache', $this->macro());
}

if (!EloquentBuilder::hasGlobalMacro('cache')) {
if (! EloquentBuilder::hasGlobalMacro('cache')) {
EloquentBuilder::macro('cache', function () {
/** @var \Illuminate\Contracts\Database\Eloquent\Builder $this */
$this->setQuery($this->getQuery()->cache(...func_get_args()));
Expand Down
10 changes: 5 additions & 5 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Laragear\CacheQuery;

use Illuminate\Contracts\Cache\LockProvider;
use Illuminate\Contracts\Cache\Repository;
use Illuminate\Contracts\Database\Query\Builder;
use LogicException;
use function base64_encode;
use function cache;
use function config;
use Illuminate\Contracts\Cache\LockProvider;
use Illuminate\Contracts\Cache\Repository;
use Illuminate\Contracts\Database\Query\Builder;
use function implode;
use LogicException;
use function md5;
use function str;

Expand All @@ -30,7 +30,7 @@ public static function store(?string $store, bool $lockable = false): Repository
{
$repository = cache()->store($store ?? config('cache-query.store'));

if ($lockable && !$repository->getStore() instanceof LockProvider) {
if ($lockable && ! $repository->getStore() instanceof LockProvider) {
$store ??= cache()->getDefaultDriver();

throw new LogicException("The [$store] cache does not support atomic locks.");
Expand Down
4 changes: 2 additions & 2 deletions tests/CacheAwareProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function setUp(): void
{
parent::setUp();

for ($i = 0; $i < 10; ++$i) {
for ($i = 0; $i < 10; $i++) {
$users[] = [
'email' => $this->faker->freeEmail,
'name' => $this->faker->name,
Expand All @@ -37,7 +37,7 @@ protected function setUp(): void

$this->app->make('db')->table('users')->insert($users);

for ($i = 0; $i < 6; ++$i) {
for ($i = 0; $i < 6; $i++) {
$posts[] = [
'title' => $this->faker->text(20),
'user_id' => (int) floor(max(1, $i / 2)),
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ protected function getPackageProviders($app): array
{
return [CacheQueryServiceProvider::class];
}
}
}

0 comments on commit dcf7952

Please sign in to comment.