yufish / memcached-session-manager

Automatically exported from code.google.com/p/memcached-session-manager
0 stars 0 forks source link

Support pluggable validity serializer #160

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently the flexjson serializer seems only to serialize the session data. 
Validity information is still handled via custom byte[] processing in the main 
package of memcached-session-manager. This results in some data being sent to 
memcached as binary and some as json (with that particular serializer).

Original issue reported on code.google.com by downch...@gmail.com on 5 Apr 2013 at 8:04

GoogleCodeExporter commented 9 years ago
This would be a good improvement, pull requests highly appreciated! :-)

Original comment by martin.grotzke on 5 Apr 2013 at 8:18

GoogleCodeExporter commented 9 years ago
Does the current JSON package actually save raw json to memcache or is it 
passed through some kind of deflate or other binary filter? I switched over to 
Jackson for JSON but I'm still getting binary data in the Memcached sessions.

Original comment by downch...@gmail.com on 5 Apr 2013 at 11:22

GoogleCodeExporter commented 9 years ago
For anyone reading, these are the two files to tweak.

core/src/main/java/de/javakaffee/web/msm/TranscoderService.java
core/src/main/java/de/javakaffee/web/msm/SessionValidityInfo.java

TranscoderService prepends a byte array of serializeSessionFields before the 
transcoder  data. SessionValidityInfo is the simple validity:* key, and is easy 
to convert. No promises on submitting a pull request, but I'll try to get there.

Original comment by downch...@gmail.com on 5 Apr 2013 at 11:55

GoogleCodeExporter commented 9 years ago
IIRC spymemcached applies compression as soon as some threshold is exceeded, 
you might want to be able to influence this.

Original comment by martin.grotzke on 6 Apr 2013 at 7:11

GoogleCodeExporter commented 9 years ago
For my use, I also had to add key prefixes to the memcached set calls and some 
instanceof String checks on a few memcached get lines. spymemcached does need 
compression turned off for other use cases (my strings are small enough); it's 
mentioned in a thread to use:

MemcachedClient c = new MemcachedClient(new InetSocketAddress("127.0.0.1", 
11211));
SerializingTranscoder serializingTranscoder = new SerializingTranscoder();
serializingTranscoder.setCompressionThreshold(Integer.MAX_VALUE);
c.set("testkey", 3600, "testvalue", serializingTranscoder);

https://groups.google.com/d/msg/spymemcached/tRD_lSEdXdk/RcVrWaByNJEJ

Original comment by downch...@gmail.com on 7 Apr 2013 at 11:22

GoogleCodeExporter commented 9 years ago
SessionIdFormat should be used more often. It does carry createLockName and 
createBackupKey. It ought to handle creating a bare key as well as any other 
keys used with memcached.

Original comment by downch...@gmail.com on 8 Apr 2013 at 2:22