Jetty服务器是否需要将EhCache核心库作为依赖项?

huangapple go评论78阅读模式
英文:

Does Jetty server require EhCache core library as dependency?

问题

  1. 我的Java应用程序正在使用Jetty(v9.4)作为服务器。我想知道它是否需要ehcache-core作为依赖,例如用于会话管理等方面?

  2. 当应用程序是无状态的时候,是否需要ehcache-core

英文:
  1. My Java application is using Jetty (v9.4) as server. I am wondering whether it requires ehcache-core as dependency for any reason such as Session management etc?

  2. Would ehcache-core be required when the application is stateless?

答案1

得分: 2

Eclipse Jetty在其任何组件中都不依赖于ehcache。

Jetty中的会话管理

  • 服务器拥有一个SessionIdManager
    • 管理每个ServletContext(例如:每个部署的Web应用)
      • 每个ServletContext有一个SessionCache
        • 每个SessionCache有一个SessionDataStore

SessionIdManager没有真正的选项,只有一个实现。

对于SessionCache,Jetty中有以下实现:

  • 如果未配置,将会有一个DefaultSessionCache(它本身无法配置)
  • session-cache-hash - 将使用内存中的HashMap来跟踪会话。
  • session-cache-null - 不会在ServletContext级别缓存Session(这在某些情况下是非常有用的配置,只是意味着您会更多地依赖于SessionDataStore

SessionCache可以在每个ServletContext中进行特定配置,还可以通过SessionCacheFactory实现在服务器级别进行配置,该实现将在部署新Web应用程序时使用。

对于SessionDataStore,您可以使用以下几种实现:

  • Null - 不存储会话(仅依赖于缓存)

  • File - 将会话持久化到磁盘

  • JDBC - 将会话持久化到数据源

  • Cache - 将会话持久化到Memcache

  • GCloud - 将会话持久化到Google Cloud Storage

  • Mongo - 将会话持久化到MongoDB

  • Infinispan - 将会话持久化到Infinispan

英文:

Eclipse Jetty has no dependency on ehcache in any of it's components.

Session Management in Jetty.

  • Server has a SessionIdManager
    • Manages each ServletContext (eg: each deployed webapp)
      • A SessionCache per ServletContext
        • A SessionDataStore per SessionCache

There's no real options for SessionIdManager there's just one implementation.

For SessionCache you have the following implementations in Jetty.

  • If unconfigured, you'll have a DefaultSessionCache (which itself cannot be configured)
  • session-cache-hash - will use an in memory HashMap to track sessions.
  • session-cache-null - will not cache Session at ServletContext level (this is sometimes a very useful configuration, just means you'll lean more on the SessionDataStore)

The SessionCache can be specifically configured at each ServletContext, but it can also be configured at the Server level via a SessionCacheFactory implementation that will be used when a new webapp is deployed.

For SessionDataStore you have several implementations available.

  • Null - no storage of Sessions (you rely on Cache only)

  • File - Session persistence to disk

  • JDBC - Session persistence to a DataSource

  • Cache - Session persistence to Memcache

  • GCloud - Session persistence to Google Cloud Storage

  • Mongo - Session persistence to Mongo DB

  • Infinispan - Session persistence to Infinispan

huangapple
  • 本文由 发表于 2020年8月28日 18:46:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/63632282.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定