Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to invalidate cache manually #263

Open
apuatcfbd opened this issue Mar 8, 2021 · 2 comments
Open

No way to invalidate cache manually #263

apuatcfbd opened this issue Mar 8, 2021 · 2 comments

Comments

@apuatcfbd
Copy link

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.

@apuatcfbd apuatcfbd changed the title No way to invalidate cache No way to invalidate cache manually Mar 8, 2021
@apuatcfbd
Copy link
Author

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}");
    }
}

@kodeine
Copy link
Owner

kodeine commented May 5, 2021

Can you please share a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants