You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.markdown
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,44 @@ Copy the tomcat-redis-session-manager.jar and jedis-2.0.0.jar files into the `li
38
38
39
39
Reboot the server, and sessions should now be stored in Redis.
40
40
41
+
Session Change Tracking
42
+
-----------------------
43
+
44
+
As noted in the "Overview" section above, in order to prevent colliding writes, the Redis Session Manager only serializes the session object into Redis if the session object has changed (it always updates the expiration separately however.) This dirty tracking marks the session as needing serialization according to the following rules:
45
+
46
+
* Calling `session.removeAttribute(key)` always marks the session as dirty (needing serialization.)
47
+
* Calling `session.setAttribute(key, newAttributeValue)` marks the session as dirty if any of the following are true:
This feature can have the unintended consequence of hiding writes if you implicitly change a key in the session or if the object's equality does not change even though the key is updated. For example, assuming the session already contains the key `"myArray"` with an Array instance as its corresponding value, and has been previously serialized, the following code would not cause the session to be serialized again:
54
+
55
+
List myArray = session.getAttribute("myArray");
56
+
myArray.add(additionalArrayValue);
57
+
58
+
If your code makes these kind of changes, then the RedisSession provides a mechanism by which you can mark the session as dirty in order to guarantee serialization at the end of the request. For example:
59
+
60
+
List myArray = session.getAttribute("myArray");
61
+
myArray.add(additionalArrayValue);
62
+
session.setAttribute("__changed__");
63
+
64
+
In order to not cause issues with an application that may already use the key `"__changed__"`, this feature is disabled by default. To enable this feature, simple call the following code in your application's initialization:
0 commit comments