public class CasKryoTranscoder
extends java.lang.Object
implements net.spy.memcached.transcoders.Transcoder<java.lang.Object>
MemcachedClient
transcoder implementation based on Kryo fast serialization framework
suited for efficient serialization of tickets.
We can’t use an auto-register type approach, because the sequence of class registration has to be deterministic. So – for example – if we register in the sequence in which we encounter classes, then if you have two (or more) instances of CAS running (e.g. for HA or horizontal scaling), then they would likely register classes in a different sequence. The sequence is a factor in assigning an internal Kryo integer id to each class. And, Kryo serializes be embedding that class id into the object, rather than the class name (makes for a much smaller serialized entity). So – if the same class gets registered in both instances, but get different id’s, then the same cached object would deserialize differently (if we’re lucky it would throw an exception, if we’re unlucky it would contain bad data). Or – a class gets registered in one instance, but not the other. So – it needs to be pre-registered, and in a deterministic sequence.
Constructor and Description |
---|
CasKryoTranscoder() |
Modifier and Type | Method and Description |
---|---|
boolean |
asyncDecode(net.spy.memcached.CachedData d)
Asynchronous decoding is not supported.
|
java.lang.Object |
decode(net.spy.memcached.CachedData d) |
net.spy.memcached.CachedData |
encode(java.lang.Object obj) |
CloseableKryo |
getKryo()
Gets kryo.
|
int |
getMaxSize()
Maximum size of encoded data supported by this transcoder.
|
public boolean asyncDecode(net.spy.memcached.CachedData d)
asyncDecode
in interface net.spy.memcached.transcoders.Transcoder<java.lang.Object>
d
- Data to decode.public net.spy.memcached.CachedData encode(java.lang.Object obj)
encode
in interface net.spy.memcached.transcoders.Transcoder<java.lang.Object>
public java.lang.Object decode(net.spy.memcached.CachedData d)
decode
in interface net.spy.memcached.transcoders.Transcoder<java.lang.Object>
public int getMaxSize()
getMaxSize
in interface net.spy.memcached.transcoders.Transcoder<java.lang.Object>
net.spy.memcached.CachedData#MAX_SIZE
.public CloseableKryo getKryo()