You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
--Copyright 2021 The casbin Authors. All Rights Reserved.
2
+
--
3
+
--Licensed under the Apache License, Version 2.0 (the "License");
4
+
--you may not use this file except in compliance with the License.
5
+
--You may obtain a copy of the License at
6
+
--
7
+
-- http://www.apache.org/licenses/LICENSE-2.0
8
+
--
9
+
--Unless required by applicable law or agreed to in writing, software
10
+
--distributed under the License is distributed on an "AS IS" BASIS,
11
+
--WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+
--See the License for the specific language governing permissions and
13
+
--limitations under the License.
14
+
15
+
require("src.main.Enforcer")
16
+
17
+
-- CachedEnforcer wraps Enforcer and provides decision cache
18
+
CachedEnforcer= {}
19
+
setmetatable(CachedEnforcer, Enforcer)
20
+
21
+
-- Creates a cached enforcer via file or DB.
22
+
functionCachedEnforcer:new(model, adapter)
23
+
locale=Enforcer:new(model, adapter)
24
+
self.__index=self
25
+
setmetatable(e, self)
26
+
e.cacheEnabled=true
27
+
e.m= {}
28
+
returne
29
+
end
30
+
31
+
-- enableCache determines whether to enable cache on Enforce(). When enableCache is enabled, cached result (true | false) will be returned for previous decisions.
32
+
functionCachedEnforcer:enableCache(enabled)
33
+
ifenabledthen
34
+
self.cacheEnabled=true
35
+
else
36
+
self.cacheEnabled=false
37
+
end
38
+
end
39
+
40
+
-- enforce decides whether a "subject" can access a "object" with the operation "action", input parameters are usually: (sub, obj, act).
0 commit comments