@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $usesCachableTrait = collect(class_uses($this)) |
| 35 | 35 | ->contains("GeneaLabs\LaravelModelCaching\Traits\Cachable"); |
| 36 | 36 | |
| 37 | - if (! $usesCachableTrait) { |
|
| 37 | + if (!$usesCachableTrait) { |
|
| 38 | 38 | array_push($tags, str_slug(get_called_class())); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | if ($cacheCooldown) { |
| 62 | 62 | $cachePrefix = "genealabs:laravel-model-caching:" |
| 63 | 63 | . (config('laravel-model-caching.cache-prefix') |
| 64 | - ? config('laravel-model-caching.cache-prefix', '') . ":" |
|
| 64 | + ? config('laravel-model-caching.cache-prefix', '').":" |
|
| 65 | 65 | : ""); |
| 66 | 66 | $modelClassName = get_class($this); |
| 67 | 67 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at"; |
| 68 | 68 | |
| 69 | 69 | $this->cache() |
| 70 | - ->rememberForever($cacheKey, function () { |
|
| 70 | + ->rememberForever($cacheKey, function() { |
|
| 71 | 71 | return now(); |
| 72 | 72 | }); |
| 73 | 73 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | { |
| 99 | 99 | $cachePrefix = "genealabs:laravel-model-caching:" |
| 100 | 100 | . (config('laravel-model-caching.cache-prefix') |
| 101 | - ? config('laravel-model-caching.cache-prefix', '') . ":" |
|
| 101 | + ? config('laravel-model-caching.cache-prefix', '').":" |
|
| 102 | 102 | : ""); |
| 103 | 103 | $modelClassName = get_class($instance); |
| 104 | 104 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | ->cache() |
| 107 | 107 | ->get("{$cachePrefix}:{$modelClassName}-cooldown:seconds"); |
| 108 | 108 | |
| 109 | - if (! $cacheCooldown) { |
|
| 109 | + if (!$cacheCooldown) { |
|
| 110 | 110 | return [null, null, null]; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | { |
| 130 | 130 | [$cacheCooldown, $invalidatedAt] = $this->getModelCacheCooldown($instance); |
| 131 | 131 | |
| 132 | - if (! $cacheCooldown) { |
|
| 132 | + if (!$cacheCooldown) { |
|
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | if (now()->diffInSeconds($invalidatedAt) >= $cacheCooldown) { |
| 137 | 137 | $cachePrefix = "genealabs:laravel-model-caching:" |
| 138 | 138 | . (config('laravel-model-caching.cache-prefix') |
| 139 | - ? config('laravel-model-caching.cache-prefix', '') . ":" |
|
| 139 | + ? config('laravel-model-caching.cache-prefix', '').":" |
|
| 140 | 140 | : ""); |
| 141 | 141 | $modelClassName = get_class($instance); |
| 142 | 142 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | [$cacheCooldown, $invalidatedAt, $savedAt] = $instance->getModelCacheCooldown($instance); |
| 159 | 159 | |
| 160 | - if (! $cacheCooldown) { |
|
| 160 | + if (!$cacheCooldown) { |
|
| 161 | 161 | $instance->flushCache(); |
| 162 | 162 | |
| 163 | 163 | return; |
@@ -166,13 +166,13 @@ discard block |
||
| 166 | 166 | if ($cacheCooldown) { |
| 167 | 167 | $cachePrefix = "genealabs:laravel-model-caching:" |
| 168 | 168 | . (config('laravel-model-caching.cache-prefix') |
| 169 | - ? config('laravel-model-caching.cache-prefix', '') . ":" |
|
| 169 | + ? config('laravel-model-caching.cache-prefix', '').":" |
|
| 170 | 170 | : ""); |
| 171 | 171 | $modelClassName = get_class($instance); |
| 172 | 172 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:saved-at"; |
| 173 | 173 | |
| 174 | 174 | $instance->cache() |
| 175 | - ->rememberForever($cacheKey, function () { |
|
| 175 | + ->rememberForever($cacheKey, function() { |
|
| 176 | 176 | return now(); |
| 177 | 177 | }); |
| 178 | 178 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | public static function bootCachable() |
| 188 | 188 | { |
| 189 | 189 | // TODO: add for deleted,updated,etc? |
| 190 | - static::saved(function ($instance) { |
|
| 190 | + static::saved(function($instance) { |
|
| 191 | 191 | $instance->checkCooldownAndFlushAfterPersiting($instance); |
| 192 | 192 | }); |
| 193 | 193 | } |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | $key = $instance->makeCacheKey(); |
| 205 | 205 | |
| 206 | 206 | return $instance->cache($tags) |
| 207 | - ->rememberForever($key, function () use ($columns) { |
|
| 207 | + ->rememberForever($key, function() use ($columns) { |
|
| 208 | 208 | return parent::all($columns); |
| 209 | 209 | }); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | public function newEloquentBuilder($query) |
| 213 | 213 | { |
| 214 | - if (! $this->isCachable()) { |
|
| 214 | + if (!$this->isCachable()) { |
|
| 215 | 215 | $this->isCachable = true; |
| 216 | 216 | |
| 217 | 217 | return new EloquentBuilder($query); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | public function isCachable() : bool |
| 224 | 224 | { |
| 225 | 225 | return $this->isCachable |
| 226 | - && ! config('laravel-model-caching.disabled'); |
|
| 226 | + && !config('laravel-model-caching.disabled'); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | public function scopeWithCacheCooldownSeconds( |
@@ -232,19 +232,19 @@ discard block |
||
| 232 | 232 | ) : EloquentBuilder { |
| 233 | 233 | $cachePrefix = "genealabs:laravel-model-caching:" |
| 234 | 234 | . (config('laravel-model-caching.cache-prefix') |
| 235 | - ? config('laravel-model-caching.cache-prefix', '') . ":" |
|
| 235 | + ? config('laravel-model-caching.cache-prefix', '').":" |
|
| 236 | 236 | : ""); |
| 237 | 237 | $modelClassName = get_class($this); |
| 238 | 238 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:seconds"; |
| 239 | 239 | |
| 240 | 240 | $this->cache() |
| 241 | - ->rememberForever($cacheKey, function () use ($seconds) { |
|
| 241 | + ->rememberForever($cacheKey, function() use ($seconds) { |
|
| 242 | 242 | return $seconds; |
| 243 | 243 | }); |
| 244 | 244 | |
| 245 | 245 | $cacheKey = "{$cachePrefix}:{$modelClassName}-cooldown:invalidated-at"; |
| 246 | 246 | $this->cache() |
| 247 | - ->rememberForever($cacheKey, function () { |
|
| 247 | + ->rememberForever($cacheKey, function() { |
|
| 248 | 248 | return now(); |
| 249 | 249 | }); |
| 250 | 250 | |