Skip to content
Browse files

Adds setCompressionMode to Transcoder

  • Loading branch information...
1 parent c7184a4 commit a04487642c905cd56f1bd84ecb8868c330de4bd7 @killme2008 committed Mar 18, 2012
View
6 src/main/java/net/rubyeye/xmemcached/transcoders/BaseSerializingTranscoder.java
@@ -29,7 +29,7 @@
protected int compressionThreshold = DEFAULT_COMPRESSION_THRESHOLD;
protected String charset = DEFAULT_CHARSET;
- protected CompressMode compressMode = CompressMode.GZIP;
+ protected CompressionMode compressMode = CompressionMode.GZIP;
protected static final Logger log = LoggerFactory
.getLogger(BaseSerializingTranscoder.class);
@@ -45,11 +45,11 @@ public void setCompressionThreshold(int to) {
this.compressionThreshold = to;
}
- public CompressMode getCompressMode() {
+ public CompressionMode getCompressMode() {
return compressMode;
}
- public void setCompressMode(CompressMode compressMode) {
+ public void setCompressionMode(CompressionMode compressMode) {
this.compressMode = compressMode;
}
View
18 src/main/java/net/rubyeye/xmemcached/transcoders/CompressionMode.java
@@ -0,0 +1,18 @@
+package net.rubyeye.xmemcached.transcoders;
+
+/**
+ * Compress mode for compressing data
+ *
+ * @author apple
+ *
+ */
+public enum CompressionMode {
+ /**
+ * Gzip mode
+ */
+ GZIP,
+ /**
+ * Zip mode
+ */
+ ZIP
+}
View
6 src/main/java/net/rubyeye/xmemcached/transcoders/TokyoTyrantTranscoder.java
@@ -62,6 +62,12 @@ public final Object decode(CachedData d) {
flag = flag & SerializingTranscoder.SPECIAL_MASK;
return serializingTranscoder.decode0(d, realData, flag);
}
+
+
+
+ public void setCompressionMode(CompressionMode compressMode) {
+ this.serializingTranscoder.setCompressionMode(compressMode);
+ }
public final CachedData encode(Object o) {
CachedData result = serializingTranscoder.encode(o);
View
20 src/main/java/net/rubyeye/xmemcached/transcoders/Transcoder.java
@@ -39,10 +39,28 @@
* @param primitiveAsString
*/
public void setPackZeros(boolean packZeros);
-
+ /**
+ * Set compression threshold in bytes
+ * @param to
+ */
public void setCompressionThreshold(int to);
+ /**
+ * Returns if client stores primitive type as string.
+ * @return
+ */
public boolean isPrimitiveAsString();
+ /**
+ * Returns if transcoder packs zero.
+ * @return
+ */
public boolean isPackZeros();
+
+ /**
+ * Set compress mode,default is ZIP
+ * @see CompressionMode
+ * @param compressMode
+ */
+ public void setCompressionMode(CompressionMode compressMode);
}
View
6 src/test/java/net/rubyeye/xmemcached/test/unittest/transcoder/SerializingTranscoderTest.java
@@ -6,7 +6,7 @@
import java.util.Calendar;
import net.rubyeye.xmemcached.transcoders.CachedData;
-import net.rubyeye.xmemcached.transcoders.CompressMode;
+import net.rubyeye.xmemcached.transcoders.CompressionMode;
import net.rubyeye.xmemcached.transcoders.SerializingTranscoder;
import net.rubyeye.xmemcached.transcoders.TranscoderUtils;
@@ -74,13 +74,13 @@ public void testCompressedObject() throws Exception {
public void testCompressedObjectDecompressZipMode() throws Exception {
tc.setCompressionThreshold(8);
- tc.setCompressMode(CompressMode.ZIP);
+ tc.setCompressionMode(CompressionMode.ZIP);
Calendar c = Calendar.getInstance();
CachedData cd = tc.encode(c);
assertEquals(SerializingTranscoder.SERIALIZED
| SerializingTranscoder.COMPRESSED, cd.getFlag());
assertEquals(c, tc.decode(cd));
- tc.setCompressMode(CompressMode.GZIP);
+ tc.setCompressionMode(CompressionMode.GZIP);
}
public void testUnencodeable() throws Exception {

0 comments on commit a044876

Please sign in to comment.
Something went wrong with that request. Please try again.