File tree Expand file tree Collapse file tree 4 files changed +39
-2
lines changed
java/com/springboot/cloud/auth/authentication Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 3737 <groupId >io.springfox</groupId >
3838 <artifactId >springfox-swagger-ui</artifactId >
3939 </dependency >
40+ <!-- jetcache缓存 -->
41+ <dependency >
42+ <groupId >com.alicp.jetcache</groupId >
43+ <artifactId >jetcache-starter-redis</artifactId >
44+ </dependency >
4045 </dependencies >
4146
4247 <build >
Original file line number Diff line number Diff line change 11package com .springboot .cloud .auth .authentication ;
22
3+ import com .alicp .jetcache .anno .config .EnableCreateCacheAnnotation ;
34import org .springframework .boot .SpringApplication ;
45import org .springframework .boot .autoconfigure .SpringBootApplication ;
56import org .springframework .cloud .client .discovery .EnableDiscoveryClient ;
89@ SpringBootApplication
910@ EnableDiscoveryClient
1011@ EnableFeignClients
12+ @ EnableCreateCacheAnnotation
1113public class Oauth2AuthenticationApplication {
1214 public static void main (String [] args ) {
1315 SpringApplication .run (Oauth2AuthenticationApplication .class , args );
Original file line number Diff line number Diff line change 11package com .springboot .cloud .auth .authentication .service .impl ;
22
3- import com .springboot . cloud . auth . authentication . service . IResourceService ;
4- import com .springboot . cloud . sysadmin . organization . entity . po . Resource ;
3+ import com .alicp . jetcache . anno . CacheType ;
4+ import com .alicp . jetcache . anno . Cached ;
55import com .springboot .cloud .auth .authentication .provider .ResourceProvider ;
6+ import com .springboot .cloud .auth .authentication .service .IResourceService ;
67import com .springboot .cloud .auth .authentication .service .NewMvcRequestMatcher ;
8+ import com .springboot .cloud .sysadmin .organization .entity .po .Resource ;
79import lombok .extern .slf4j .Slf4j ;
810import org .springframework .beans .factory .annotation .Autowired ;
911import org .springframework .security .access .ConfigAttribute ;
@@ -71,6 +73,7 @@ public ConfigAttribute findConfigAttributesByUrl(HttpServletRequest authRequest)
7173 }
7274
7375 @ Override
76+ @ Cached (name = "resource4user::" , key = "#username" , cacheType = CacheType .BOTH )
7477 public Set <Resource > queryByUsername (String username ) {
7578 return resourceProvider .resources (username ).getData ();
7679 }
Original file line number Diff line number Diff line change @@ -34,6 +34,33 @@ feign:
3434 okhttp :
3535 enabled : true
3636
37+
38+ jetcache :
39+ statIntervalMinutes : 15
40+ areaInCacheName : false
41+ hidePackages : com.springboot.cloud
42+ local :
43+ # 短時本地緩存,主要用于要求时效较高的配置
44+ default :
45+ type : caffeine
46+ keyConvertor : fastjson
47+ expireAfterWriteInMillis : 60000
48+ expireAfterAccessInMillis : 40000
49+ remote :
50+ # 默认2分钟的远程缓存
51+ default :
52+ type : redis
53+ expireAfterWriteInMillis : 120000
54+ keyConvertor : fastjson
55+ valueEncoder : kryo
56+ valueDecoder : kryo
57+ poolConfig :
58+ minIdle : 5
59+ maxIdle : 20
60+ maxTotal : 50
61+ host : ${REDIS_HOST:localhost}
62+ port : ${REDIS_PORT:6379}
63+
3764logging :
3865 level :
3966 com.springboot.cloud : debug
You can’t perform that action at this time.
0 commit comments