Skip to main content


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

Supported Enforcers

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

EnforcerCasbinThe Enforcer is the basic structure for users to interact with Casbin policies and models. You can find more details about the Enforcer API here.
CachedEnforcerCasbinThe CachedEnforcer is based on the Enforcer and supports caching the evaluation result of a request in memory using a map. It provides the ability to clear caches within a specified expiration time. Moreover, it guarantees thread safety with a Read-Write lock. You can use EnableCache to enable caching of evaluation results (default is enabled). The other API methods of CachedEnforcer are the same as Enforcer.
DistributedEnforcerCasbinThe DistributedEnforcer supports multiple instances in distributed clusters. It wraps the SyncedEnforcer for the dispatcher. You can find more details about the dispatcher here.
SyncedEnforcerCasbinThe SyncedEnforcer is based on the Enforcer and provides synchronized access. It is thread-safe.
SyncedCachedEnforcerCasbinThe SyncedCachedEnforcer wraps the Enforcer and provides decision sync cache.