php-casbin/laravel-authz

What if I want to get a new instance?

guoliang1994 opened this issue · 3 comments

When I use it in workerman, the data I get is always the same,What should I do if I want to get a new instance.

 $policy = Enforcer::getPolicy();

Even if my database has been updated, this method always returns the old data,

The following method is singleton mode

    /**
     * Attempt to get the enforcer from the local cache.
     *
     * @param string $name
     *
     * @return \Casbin\Enforcer
     *
     * @throws \InvalidArgumentException
     */
    public function guard($name = null)
    {
        $name = $name ?: $this->getDefaultGuard();

        if (!isset($this->guards[$name])) {
            $this->guards[$name] = $this->resolve($name);
        }
        return $this->guards[$name];
    }

@basakest @techoner

@techoner @basakest

@guoliang1994 Workman is multi-process, we need to use watcher to synchronize : https://github.com/php-casbin/workerman-redis-watcher