File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -14,16 +14,16 @@ class CacheHandler implements CacheHandlerContract
1414     * Cache policies for the given model. 
1515     * 
1616     * @param Rule $model The model to cache policies for. 
17-      * @return Query The cached query or a new query  if caching is disabled. 
17+      * @return Query|Rule  The cached query if caching is disabled, or origin Rule . 
1818     */ 
19-     public  function  cachePolicies (Rule $ modelQuery 
19+     public  function  cachePolicies (Rule $ modelQuery | Rule 
2020    {
2121        if  ($ this config ('cache.enabled ' , false )) {
2222            $ key$ this config ('cache.key ' , 'tauthz ' );
2323            $ expire$ this config ('cache.expire ' , 0 );
2424            return  $ modelcache ($ key$ expire
2525        } else  {
26-             return  $ model-> newQuery () ;
26+             return  $ model
2727        }
2828    }
2929}
Original file line number Diff line number Diff line change 77
88interface  CacheHandlerContract
99{
10-     public  function  cachePolicies (Rule $ modelQuery 
10+     public  function  cachePolicies (Rule $ modelQuery | Rule 
1111}
Original file line number Diff line number Diff line change @@ -358,17 +358,17 @@ public function testCachePolicies()
358358            $ startmicrotime (true );
359359            Enforcer::loadPolicy ();
360360            $ endmicrotime (true );
361-             $ timeEnabled $ end$ start
361+             $ timeDisabled $ end$ start
362362            // time cost if cache is disabled 
363363            $ driverconfig ('tauthz.default ' );
364364            config (['enforcers '  => [$ driver
365-                 'cache '  => ['enabled '  => false ],
365+                 'cache '  => ['enabled '  => true ],
366366                'database '  => ['rules_name '  => 'rules ' ]
367367            ]]], 'tauthz ' );
368368            $ startmicrotime (true );
369369            Enforcer::loadPolicy ();
370370            $ endmicrotime (true );
371-             $ timeDisabled $ end$ start
371+             $ timeEnabled $ end$ start
372372            // ensure time cost is not greater than time cost if cache is disabled 
373373            $ this assertTrue ($ timeEnabled$ timeDisabled
374374        });
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments