Open apuatcfbd opened 3 years ago
As there's no way to invalidate cache, I've created a trait to do so . Don't know if the keys I'm passing is absolutely correct or not. But it's working.
namespace App\Traits;
use Illuminate\Support\Facades\Cache;
trait AclCache
{
public function invalidatePermissionCache(int $roleId) :void
{
Cache::forget("acl.getPermissionsInheritedById_{$roleId}");
Cache::forget("acl.getPermissionsById_{$roleId}");
Cache::forget("acl.getMergeById_{$roleId}");
}
public function invalidateRoleCache(int $userId) :void
{
Cache::forget("acl.getRolesById_{$userId}");
}
}
Can you please share a PR for this?
By default this package has set cache time for 1 minute. If I update permissions for a role, this will be effective in next cache interval. But there's should be an option to manually invalidate the cache.