Class BaseSerializingTranscoder
java.lang.Object
net.rubyeye.xmemcached.transcoders.BaseSerializingTranscoder
- Direct Known Subclasses:
PrimitiveTypeTranscoder
,SerializingTranscoder
,WhalinTranscoder
,WhalinV1Transcoder
Base class for any transcoders that may want to work with serialized or compressed data.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
(package private) static int
protected int
protected CompressionMode
static final String
static final int
Default compression threshold value.protected static final org.slf4j.Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal byte[]
compress
(byte[] in) Compress the given array of bytes.protected String
decodeString
(byte[] data) Decode the string with the current character set.protected byte[]
decompress
(byte[] in) Decompress the given array of bytes.protected Object
deserialize
(byte[] in) Get the object represented by the given serialized bytes.protected byte[]
encodeString
(String in) Encode a string into the current character set.private static byte[]
gzipCompress
(byte[] in) private byte[]
gzipDecompress
(byte[] in) protected byte[]
Get the bytes representing the given serialized object.void
setCharset
(String to) Set the character set for string value transcoding (defaults to UTF-8).void
setCompressionMode
(CompressionMode compressMode) void
setCompressionThreshold
(int to) Set the compression threshold to the given number of bytes.private byte[]
zipCompress
(byte[] in) private byte[]
zipDecompress
(byte[] in)
-
Field Details
-
DEFAULT_COMPRESSION_THRESHOLD
public static final int DEFAULT_COMPRESSION_THRESHOLDDefault compression threshold value.- See Also:
-
DEFAULT_CHARSET
- See Also:
-
compressionThreshold
protected int compressionThreshold -
charset
-
compressMode
-
log
protected static final org.slf4j.Logger log -
COMPRESS_RATIO
static int COMPRESS_RATIO
-
-
Constructor Details
-
BaseSerializingTranscoder
public BaseSerializingTranscoder()
-
-
Method Details
-
setCompressionThreshold
public void setCompressionThreshold(int to) Set the compression threshold to the given number of bytes. This transcoder will attempt to compress any data being stored that's larger than this.- Parameters:
to
- the number of bytes
-
getCompressMode
-
setCompressionMode
-
setCharset
Set the character set for string value transcoding (defaults to UTF-8). -
serialize
Get the bytes representing the given serialized object. -
deserialize
Get the object represented by the given serialized bytes. -
compress
public final byte[] compress(byte[] in) Compress the given array of bytes. -
zipCompress
private byte[] zipCompress(byte[] in) -
gzipCompress
private static byte[] gzipCompress(byte[] in) -
decompress
protected byte[] decompress(byte[] in) Decompress the given array of bytes.- Returns:
- null if the bytes cannot be decompressed
-
zipDecompress
private byte[] zipDecompress(byte[] in) -
gzipDecompress
private byte[] gzipDecompress(byte[] in) -
decodeString
Decode the string with the current character set. -
encodeString
Encode a string into the current character set.
-