Remove disable cache in favor flush/forget
This commit is contained in:
parent
6cfa914fe8
commit
a6e208a88e
|
@ -218,7 +218,7 @@ class Form extends Model implements CachableAttributes
|
||||||
|
|
||||||
public function getMaxNumberOfSubmissionsReachedAttribute()
|
public function getMaxNumberOfSubmissionsReachedAttribute()
|
||||||
{
|
{
|
||||||
$this->disableCache('submissions_count');
|
$this->forget('submissions_count');
|
||||||
return ($this->max_submissions_count && $this->max_submissions_count <= $this->submissions_count);
|
return ($this->max_submissions_count && $this->max_submissions_count <= $this->submissions_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@ trait CachesAttributes
|
||||||
/** @var array<string, mixed> */
|
/** @var array<string, mixed> */
|
||||||
protected $attributeCache = [];
|
protected $attributeCache = [];
|
||||||
|
|
||||||
protected $disabledCache = [];
|
|
||||||
|
|
||||||
public static function bootCachesAttributes(): void
|
public static function bootCachesAttributes(): void
|
||||||
{
|
{
|
||||||
static::deleting(function (Model $model): void {
|
static::deleting(function (Model $model): void {
|
||||||
|
@ -30,18 +28,8 @@ trait CachesAttributes
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disableCache($key)
|
|
||||||
{
|
|
||||||
$this->disabledCache[] = $key;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function remember(string $attribute, ?int $ttl, Closure $callback)
|
public function remember(string $attribute, ?int $ttl, Closure $callback)
|
||||||
{
|
{
|
||||||
if (in_array($attribute, $this->disabledCache)) {
|
|
||||||
return value($callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ttl === 0 || ! $this->exists) {
|
if ($ttl === 0 || ! $this->exists) {
|
||||||
if (! isset($this->attributeCache[$attribute])) {
|
if (! isset($this->attributeCache[$attribute])) {
|
||||||
$this->attributeCache[$attribute] = value($callback);
|
$this->attributeCache[$attribute] = value($callback);
|
||||||
|
|
Loading…
Reference in New Issue