gpt4 book ai didi

java - 如何在集群环境中使用Spring Security OAuth

转载 作者:行者123 更新时间:2023-11-30 03:10:19 25 4
gpt4 key购买 nike

我正在使用InMemoryTokenStore,它在集群环境中不起作用。我必须将 token 存储在我们可以在集群环境中轻松访问它的地方。

我无法使用JdbcTokenStore,因为我没有数据库的访问权限。我想使用“Ehcache”或“RedisTokenStore”。请帮助我哪种方法更好以及如何使用它。

最佳答案

First of all you have a clustered environment which means, your application is handling serious business logic.

inMemory数据从一个servlet容器复制到另一个servlet容器确实昂贵。好的事情是您已经意识到要寻求更好的解决方案。

EhCache is a used to maintain cache across all the nodes in a clustered environment.

EhCache in itself is not a type of cache and is just a tool. Also, EhCache doesn't not maintain the cache, it just triggers some of the actions/services across the nodes so that each node can re-fresh/update its own cache.

  • 用于处理缓存一致性问题的技术跨集群节点包括:
  • 每次需要时从存储 (DB) 中提取数据(无缓存)。一般来说,这是一项昂贵的操作,并且具有多用户基于 Web 的应用程序中的性能影响。
  • 通过按预先配置的时间间隔进行轮询和刷新,使本地缓存保持最新状态。
  • 跨集群节点复制缓存数据。
  • 根据向集群成员通知更改的分布式事件,使本地缓存保持最新。

Redis works really well in distributed environment, especially with Redis Sentinel and Redis Cluster. My suggestion is go with Redis

这些教程将帮助您了解实现:

关于java - 如何在集群环境中使用Spring Security OAuth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33752448/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com