ข้ามไปยังเนื้อหาหลัก

Enforcers

The Enforcer serves as Casbin's primary interface, providing methods for interacting with access control policies and models.

Available Enforcers

Below is a complete list of Casbin enforcers. Third-party enforcer contributions are welcome—please let us know and we'll add them to this list.

Enforcerผู้เขียนคำอธิบาย
EnforcerCasbinThe base Enforcer provides the primary interface for policy and model operations. See the Management API documentation for detailed API information.
CachedEnforcerCasbinExtends the Enforcer with in-memory caching of enforcement results. Supports configurable cache expiration and includes thread-safe access via read-write locks. Use EnableCache to toggle caching (enabled by default). The remaining API methods match those of the base Enforcer.
DistributedEnforcerCasbinDesigned for distributed deployments, this enforcer wraps SyncedEnforcer to work with dispatchers. Additional information is available in the dispatcher documentation.
SyncedEnforcerCasbinExtends Enforcer with synchronized access for thread-safe operations.
SyncedCachedEnforcerCasbinCombines the caching features of CachedEnforcer with the synchronization of SyncedEnforcer.
ContextEnforcerCasbinImplements the IEnforcerContext interface to provide context-aware operations. Currently supports context for adapter operations like LoadPolicyCtx(), SavePolicyCtx(), AddPolicyCtx(), and RemovePolicyCtx(). This interface is designed for future expansion of context support across additional Casbin operations.