laravel-eloquent-query-cache
laravel-eloquent-query-cache copied to clipboard
flushQueryCache for specific tag not working
Please let me know if I am doing anything wrong.
To reproduce the situation:
- Model:
App\Models\User.php
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Rennokki\QueryCache\Traits\QueryCacheable;
class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable;
use QueryCacheable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'mobile', 'email', 'password', 'status',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
- In a controller method:
User::cacheFor(3600)->cacheTags(["user:1"])->find(1);
User::cacheFor(3600)->cacheTags(["user:2"])->find(2);
- In another controller method, I want to flush query cache only the
user 1
. But it flushes bothuser 1
&user 2
by usingflushQueryCache
method:
User::flushQueryCache(["user:1"]);
- If I run the first controller method once again, Both of the caches are flushed.
User::cacheFor(3600)->cacheTags(["user:1"])->find(1);
User::cacheFor(3600)->cacheTags(["user:2"])->find(2);