Redis Session Manager for Tomcat 8
==================================
Tomcat 8 / Java 8 session manager to store sessions in Redis.
Goals
-----
* Ability to use different Java Redis clients (defaults to a Redisson) with client-specific serializers (default to standard java serialization)
* Session save configuration to allow persistence [after a request|when an attribute changes]
* Ignore certain requests (e.g. for static resources)
Usage
-----
* Copy `redis-session-manager-with-dependencies-VERSION.jar` to tomcat/lib
* Default configuration: (communicates with redis on localhost:6379)
```
<Manager className="com.crimsonhexagon.rsm.redisson.SingleServerSessionManager" />
```
* Full configuration (showing default values):
```
<Manager className="com.crimsonhexagon.rsm.redisson.SingleServerSessionManager"
endpoint="localhost:6379"
sessionKeyPrefix="_rsm_"
saveOnChange="false"
forceSaveAfterRequest="false"
dirtyOnMutation="false"
ignorePattern=".*\\.(ico|png|gif|jpg|jpeg|swf|css|js)$"
maxSessionAttributeSize="-1"
maxSessionSize="-1"
allowOversizedSessions="false"
connectionPoolSize="100"
database="0"
password="<null>"
timeout="60000"
pingTimeout="1000"
retryAttempts="20"
retryInterval="1000"
/>
```
* _endpoint_: hostname:port of the redis server. Must be a primary endpoint (read/write) and not a read replicate (read-only).
* _sessionKeyPrefix_: prefix for redis keys. Useful for situations where 1 redis cluster serves multiple application clusters with potentially conflicting session IDs.
* _saveOnChange_: if _true_, the session will be persisted to redis immediately when any attribute is modified. When _false_, a modified session is persisted to redis when the request is complete.
* _forceSaveAfterRequest_: if _true_, the session will be persisted to redis when the request completes regardless of whether the session has detected a change to its state.
* _dirtyOnMutation_: see "Notes on object mutation" below.
* _ignorePattern_: Java Pattern String to be matched against the request URI (_does not include the query string_). If matched, the request will not be processed by the redis session manager.
* _maxSessionAttributeSize_: if not -1 (RedisSessionManager#DO_NOT_CHECK) specifies a maximum _encoded_ size for a session attribute value. Attributes larger than this size will be logged and will not be stored in the session.
* _maxSessionSize_: if not -1 (RedisSessionManager#DO_NOT_CHECK) specifies a maximum _encoded_ size for the entire session. Sessions larger than this size will be logged and will not be persisted to redis.
*_allowOversizedSessions_: if _true_ will allow sessions exceeding the configurations in _maxSessionAttributeSize_ and _maxSessionSize_ to be saved. An error will still be logged for any sessions exceeding the size. This attribute has no effect if neither _maxSessionAttributeSize_ nor _maxSessionSize_ are specified.
AWS ElastiCache usage
-----
Version 2.0.0 added additional support for ElastiCache Replication Groups. Applicable configuration:
```
<Manager className="com.crimsonhexagon.rsm.redisson.ElasticacheSessionManager"
nodes="node1.cache.amazonaws.com:6379 node2.cache.amazonaws.com:6379 ..."
nodePollInterval="1000"
sessionKeyPrefix="_rsm_"
saveOnChange="false"
forceSaveAfterRequest="false"
dirtyOnMutation="false"
ignorePattern=".*\\.(ico|png|gif|jpg|jpeg|swf|css|js)$"
maxSessionAttributeSize="-1"
maxSessionSize="-1"
allowOversizedSessions="false"
masterConnectionPoolSize="100"
slaveConnectionPoolSize="100"
database="0"
password="<null>"
timeout="60000"
pingTimeout="1000"
retryAttempts="20"
retryInterval="1000"
/>
```
_nodes_ is a space-separated list of all nodes in the replication group. There is no default value; failure to specify this will result in a failure to start.
_nodePollInterval_ is the interval for polling each node in the group to determine if it is the master or a slave.
Notes on object mutation
-----
* TL;DR: avoid mutation of objects pulled from the session. If you must do this, read on.
* Changes made directly to an object in the session without mutating the session will not be persisted to redis. E.g. `session.getAttribute("anObject").setFoo("bar")` will not result in the session being marked dirty. _forceSaveAfterRequest_ can be used as a workaround, but this is inefficient. A dirty workaround would be to mark the session as dirty by `session.removeAttribute("nonExistentKey")`
* It is possible for an object to be mutated and `session.setAttribute("anObject")` invoked without the session being marked as dirty due to the session object and mutated object being references to the same actual object. _dirtyOnMutation_ will mark the session as dirty whenever `setAttribute()` is invoked. This is generally safe but is disabled by default to avoid unnecessary persists.
redis-session-manager-redis-session-manager-2.2.0.zip
需积分: 0 18 浏览量
更新于2024-06-02
收藏 31KB ZIP 举报
Redis Session Manager是一款基于Redis数据库实现的会话管理工具,它主要用在Web应用程序中,用于存储用户的会话信息。在Web应用中,session是服务器端用来跟踪用户状态的重要机制,通常将用户信息如登录状态、购物车数据等存储在session中。而Redis,作为一个高性能的键值存储系统,因其内存存储特性,成为了理想的选择来缓存和管理这些session数据。
标题"redis-session-manager-redis-session-manager-2.2.0.zip"指的是Redis Session Manager的2.2.0版本的压缩包文件,这通常包含了该版本的所有源代码、文档、配置文件以及可能的二进制执行文件。这个版本可能是对之前版本的优化和功能增强,解决了已知问题,并可能引入了新的特性和性能提升。
描述中的"redis-session-manager-tar.gz-windows"表明该软件提供了适用于Windows操作系统的版本,且可以通过免费下载获取。这暗示了开发者不仅关注于Unix/Linux环境,同时也考虑到了Windows用户的需求,使得跨平台部署变得更加方便。
标签"redis"、"redis-session"和"windows"揭示了该工具的核心特点。"redis"表明它是与Redis数据库紧密相关的,"redis-session"强调其会话管理功能,而"windows"则确认了它对Windows操作系统的支持。
在压缩包的文件名称列表中,只给出了"redis-session-manager-redis-session-manager-2.2.0",这可能是整个项目的根目录或者包含项目源码的顶级文件夹。通常,这样的结构可能会包括以下部分:
1. `README`或`README.md`: 介绍项目的使用方法、配置步骤、依赖项等。
2. `src`或`java`:源代码目录,包含了实现session管理功能的类和方法。
3. `config`:配置文件,如`redis.properties`,用于设置Redis服务器连接参数。
4. `lib`:依赖的库文件,可能包含Redis客户端的JAR包或其他依赖库。
5. `bin`:可能包含可执行脚本或批处理文件,用于启动和停止session manager服务。
6. `docs`:文档,包括用户手册、API参考等。
7. `LICENSE`:软件授权协议,规定了软件的使用范围和条件。
8. `CHANGELOG`或`RELEASENOTES`:记录每个版本的更新和改进。
在实际使用Redis Session Manager时,你需要根据提供的文档配置Redis服务器的连接信息,将Web应用程序的session管理设置指向该工具,然后利用它来持久化和管理用户会话。这有助于提高应用的性能和可扩展性,尤其是在高并发场景下,避免了传统的session存储在单个服务器上可能导致的瓶颈问题。同时,由于数据存储在Redis中,还可以方便地进行数据备份和恢复,增加了系统的健壮性。

段子手-168
- 粉丝: 5170
最新资源
- 合肥万达茂BIM设计应用实践.docx
- 五层住宅楼给排水安装工程施工图预算编制.doc
- 前端mpvue后端nodejs+thinkjs+mysql微信小程序商城(准备用uniapp重构并适配多端).zip
- 电气工程机电安装施工方案.doc
- 中铁建设工程施工劳务分包合同.doc
- 毕业设计--基于微信小程序的在线免费小说应用.zip
- 泵站双向流道闸门电气控制设计.doc
- 微信小程序-美容.zip
- [江苏]河道港口建设工程监理大纲(流程图).doc
- 500kv送电线路工程施工组织设计.doc
- 基于晶体三极管的简易声控灯设计.doc
- 出纳工作管理制度.doc
- Sentry 小程序_小游戏 SDK。1.x 版本目前仅支持微信小程序_小游戏应用。.zip
- 浅谈建筑电气工程师的素质.doc
- 脚手架管理程序.docx
- 小学迁建工程工程设计合同.doc