MCPcopy
hub / github.com/apache/casbin / RemovePolicies

Method RemovePolicies

enforcer_cached.go:111–127  ·  view source on GitHub ↗
(rules [][]string)

Source from the content-addressed store, hash-verified

109}
110
111func (e *CachedEnforcer) RemovePolicies(rules [][]string) (bool, error) {
112 if len(rules) != 0 {
113 if atomic.LoadInt32(&e.enableCache) != 0 {
114 irule := make([]interface{}, len(rules[0]))
115 for _, rule := range rules {
116 for i, param := range rule {
117 irule[i] = param
118 }
119 key, _ := e.getKey(irule...)
120 if err := e.cache.Delete(key); err != nil && err != cache.ErrNoSuchKey {
121 return false, err
122 }
123 }
124 }
125 }
126 return e.Enforcer.RemovePolicies(rules)
127}
128
129func (e *CachedEnforcer) getCachedResult(key string) (res bool, err error) {
130 e.locker.Lock()

Callers 1

TestCacheFunction · 0.95

Calls 3

getKeyMethod · 0.95
DeleteMethod · 0.65
RemovePoliciesMethod · 0.65

Tested by 1

TestCacheFunction · 0.76