代码拉取完成,页面将自动刷新
#uncode-session
非常小巧的集群session共享组件,代码千行以内,避免使用应用容器插件的多种烦恼。
<!-- 会话共享过滤器,注意放在其他filter之前 -->
<filter>
<filter-name>SessionSharingFilter</filter-name>
<filter-class>cn.uncode.session.SessionSharingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SessionSharingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 配置Redis缓存池(默认基于redis实现,所以只需要配置缓存池就可以了) -->
<bean id="redisSentinelPool" class="cn.uncode.session.data.redis.RedisSentinelPool">
<property name="hosts">
<list>
<value>127.0.0.1:26379</value>
<value>127.0.0.2:26379</value>
</list>
</property>
<property name="auth" value="123456" />
<property name="maxIdle" value="5" />
<property name="maxTotal" value="20" />
<property name="maxWaitMillis" value="10000" />
<property name="testOnBorrow" value="true" />
</bean>
<bean id="sessionCache" class="cn.uncode.session.data.redis.RedisSessionCache">
<property name="cachePool" ref="redisSentinelPool" />
</bean>
<bean id="memcachedPool" class="cn.uncode.session.data.memcached.MemcachedPool">
<property name="hosts">
<list>
<value>127.0.0.1:11211</value>
</list>
</property>
</bean>
<bean id="sessionCache" class="cn.uncode.session.data.memcached.MemcachedSessionCache">
<property name="cachePool" ref="memcachedPool" />
</bean>
<bean id="sessionCacheManager" class="cn.uncode.session.data.SessionCacheManager">
<property name="sessionCache" ref="sessionCache" />
</bean>
public class CustomSessionCache implements SessionCache{
@Override
public void put(String sessionId, SessionMap sessionMap, int timeout) {
}
@Override
public SessionMap get(String sessionId) {
}
@Override
public void setMaxInactiveInterval(String sessionId, int interval) {
}
@Override
public void destroy(String sessionId) {
}
}
<!-- 配置缓存 -->
<bean id="customSessionCache" class="cn.uncode.session.*.*.CustomSessionCache" />
<!-- 配置会话缓存管理器 -->
<bean id="sessionCacheManager" class="cn.uncode.session.data.SessionCacheManager">
<property name="sessionCache" ref="customSessionCache" />
<!-- 或者使用以下配置,二选一 -->
<!--
<property name="beanName" value="customSessionCache" />
-->
</bean>
作者:冶卫军(ywj_316@qq.com,微信:yeweijun) 贡献开发:马煜
技术支持QQ群:47306892
Copyright 2016 www.uncode.cn
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。