# README
Redis Adapter 
Redis Adapter for go-redis is the Redis adapter for Casbin, but with [go-redis] (https://github.com/go-redis/redis) as its client library. With this library, Casbin can load policy from Redis or save policy to it.
Installation
go get github.com/mintxtinm/go-redis-adapter/v2
Simple Example
package main
import (
"github.com/casbin/casbin/v2"
"github.com/mintxtinm/go-redis-adapter/v2"
)
func main() {
// Initialize a Redis adapter and use it in a Casbin enforcer:
a := redisadapter.NewAdapter("tcp", "127.0.0.1:6379") // Your Redis network and address.
// Use the following if Redis has password like "123"
//a := redisadapter.NewAdapterWithPassword("tcp", "127.0.0.1:6379", "123")
e := casbin.NewEnforcer("examples/rbac_model.conf", a)
// Load the policy from DB.
e.LoadPolicy()
// Check the permission.
e.Enforce("alice", "data1", "read")
// Modify the policy.
// e.AddPolicy(...)
// e.RemovePolicy(...)
// Save the policy back to DB.
e.SavePolicy()
}
Getting Help
License
This project is under Apache 2.0 License. See the LICENSE file for the full license text.
# Functions
NewAdapter is the constructor for Adapter.
NewAdapterWithKey is the constructor for Adapter.
NewAdapterWithPassword is the constructor for Adapter.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
Adapter represents the Redis adapter for policy storage.
CasbinRule is used to determine which policy line to load.
# Type aliases
No description provided by the author