renoki-co/laravel-eloquent-query-cache

flushQueryCache for specific tag not working

ferdousanam opened this issue · 3 comments

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 both user 1 & user 2 by using flushQueryCache 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);
stale commented

This issue has been automatically closed because it has not had any recent activity. 😨

I would also like to know, seems to be the same for me.

I would also like to know, seems to be the same for me.

@moskoweb The cache driver or the service needs to support tags to work it properly.