为了满足高性能的要求,spring-oauth-server中增加了使用redis存储 AccessToken的功能,以达到更高的性能要求。
以下配置是将AccessToken存入Redis的参考步骤。
前提:使用spring-oauth-server的config分支,并已经安装Redis服务
1.pom.xml中增加spring-boot的redis dependency.
2.application.properties中增加redis的配置属性
3.配置OAuth2中TokenStore的Redis实现:RedisTokenStore
(prefix值 可根据实际需要进行修改;默认的实现使用JdbcTokenStore)
在以上配置完成后,启动redis服务,并将spring-oauth-server重启后,即完成了将AccessToken配置存入Redis的功能,
测试获取AccessToken后,可在redis中查看到对应的数据,如下所示:
spring-oauth-server的redis配置代码分支:https://gitee.com/shengzhao/spring-oauth-server/tree/config-redis/