redisadapter

package module
v0.0.0-...-2fb1c23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

Casbin Redis Adapter

Documentation

Index

Constants

View Source
const (
	PolicyKey = "casbin:policy"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

func NewFromClient

func NewFromClient(redisCli *redis.Client) (adapter *Adapter, err error)

NewFromClient returns a new instance of Adapter from an already existing go-redis client.

func NewFromURL

func NewFromURL(url string) (adapter *Adapter, err error)

NewFromDSN returns a new Adapter by using the given DSN. Format: redis://{password}:@{host}:{port}/{database} Example: redis://password:@host:6379/0

func (*Adapter) AddPolicy

func (a *Adapter) AddPolicy(_ string, ptype string, rule []string) (err error)

AddPolicy adds a policy rule to the storage.

func (*Adapter) LoadPolicy

func (a *Adapter) LoadPolicy(model model.Model) (err error)

LoadPolicy loads all policy rules from the storage.

func (*Adapter) RemoveFilteredPolicy

func (a *Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error

func (*Adapter) RemovePolicy

func (a *Adapter) RemovePolicy(_ string, ptype string, rule []string) (err error)

func (*Adapter) SavePolicy

func (a *Adapter) SavePolicy(model model.Model) (err error)

SavePolicy saves all policy rules to the storage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL