Skip to content

What if I want to get a new instance? #32

@guoliang1994

Description

@guoliang1994

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];
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions