Skip to main content

Enforcers

Enforcer is the main structure in Casbin. It acts as an interface for users to make operations on policy rules and models.

Supported enforcers

A complete list of Casbin enforcers is provided as below. Any 3rd-party contribution on a new enforcer is welcomed, please inform us and we will put it in this list:)

EnforcerAuthorDescription
EnforcerCasbinEnforcer is the basic structure for users to interact with Casbin policies and models. You can find more details of Enforcer's API at here.
CachedEnforcerCasbinCachedEnforcer is based on Enforcer. It supports to cache the evaluation result of a request in memory by a map and clear caches in a specified expire time. Moreover, it is guaranted to be thread-safe by a Read-Write lock. You can use EnableCache to enable to cache evaluation results (default is enabled). CachedEnforcer's other API is the same as Enforcer's.
DistributedEnforcerCasbinDistributedEnforcer supports multiple instances in distributed clusters. It wraps SyncedEnforcer for dispatcher. You can find more details about dispather at here.
SyncedEnforcerCasbinSyncedEnforer is based on Enforcer and provides synchronized access. It is thread-safe.