Java - Shiro - ehcache 配置
Java - Shiro - ehcache config
我在使用 Spring
(v4.1.4) 的 java 网络项目中使用 Shiro
(v1.2.3)。
我为 shiro 启用了 Ehcache
,以帮助存储 shiro 会话。
我的问题是:
我是否需要在 ehcache.xml 配置文件中为 shiro 会话定义一个 <cache>
实体,否则 shiro 会自动管理它?
简而言之,我是否需要将以下配置段放入 ehcache-shiro.xml
:
<cache name="shiro-activeSessionCache" maxElementsInMemory="10000" overflowToDisk="true" eternal="true"
timeToLiveSeconds="0" timeToIdleSeconds="0" diskPersistent="true" diskExpiryThreadIntervalSeconds="600" />
不,如果默认设置适合您,则不需要。 ehcache.xml file is part of the shiro-ehcache module and would be used by default. The setting you are quoting is identical to the one defined in this file. As the Shiro doc about session management 提到:
By default, the EhCacheManager uses a Shiro-specific ehcache.xml file
that sets up the Session cache region and the necessary settings to
ensure Sessions are stored and retrieved properly.
However, if you wish to change the cache settings, or configure your
own ehcache.xml or EHCache net.sf.ehcache.CacheManager instance, you
will need to configure the cache region to ensure that Sessions are
handled correctly.
If you look at the default ehcache.xml file, you will see the
following shiro-activeSessionCache cache configuration:
<cache name="shiro-activeSessionCache"
maxElementsInMemory="10000"
overflowToDisk="true"
eternal="true"
timeToLiveSeconds="0"
timeToIdleSeconds="0"
diskPersistent="true"
diskExpiryThreadIntervalSeconds="600"/>
If you wish to use your own ehcache.xml file, ensure that you have defined a similar cache
entry for Shiro's needs
我在使用 Spring
(v4.1.4) 的 java 网络项目中使用 Shiro
(v1.2.3)。
我为 shiro 启用了 Ehcache
,以帮助存储 shiro 会话。
我的问题是:
我是否需要在 ehcache.xml 配置文件中为 shiro 会话定义一个 <cache>
实体,否则 shiro 会自动管理它?
简而言之,我是否需要将以下配置段放入 ehcache-shiro.xml
:
<cache name="shiro-activeSessionCache" maxElementsInMemory="10000" overflowToDisk="true" eternal="true"
timeToLiveSeconds="0" timeToIdleSeconds="0" diskPersistent="true" diskExpiryThreadIntervalSeconds="600" />
不,如果默认设置适合您,则不需要。 ehcache.xml file is part of the shiro-ehcache module and would be used by default. The setting you are quoting is identical to the one defined in this file. As the Shiro doc about session management 提到:
By default, the EhCacheManager uses a Shiro-specific ehcache.xml file that sets up the Session cache region and the necessary settings to ensure Sessions are stored and retrieved properly.
However, if you wish to change the cache settings, or configure your own ehcache.xml or EHCache net.sf.ehcache.CacheManager instance, you will need to configure the cache region to ensure that Sessions are handled correctly.
If you look at the default ehcache.xml file, you will see the following shiro-activeSessionCache cache configuration:
<cache name="shiro-activeSessionCache"
maxElementsInMemory="10000"
overflowToDisk="true"
eternal="true"
timeToLiveSeconds="0"
timeToIdleSeconds="0"
diskPersistent="true"
diskExpiryThreadIntervalSeconds="600"/>
If you wish to use your own ehcache.xml file, ensure that you have defined a similar cache entry for Shiro's needs