Class MemcacheSerialization (2.0.0)

public class MemcacheSerialization

Static serialization helpers used by MemcacheServiceImpl

This class is thread-safe.

Inheritance

Object > MemcacheSerialization

Static Fields

USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY

public static final String USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY
Field Value
TypeDescription
String

Static Methods

deserialize(byte[] value, int flags)

public static Object deserialize(byte[] value, int flags)

Deserialize the object, according to its flags. This would have private visibility, but is also used by LocalMemcacheService for the increment operation.

Parameters
NameDescription
valuebyte[]
flagsint
Returns
TypeDescription
Object

the Object originally stored

Exceptions
TypeDescription
ClassNotFoundException

if the object can't be re-instantiated due to being an unlocatable type

IOException

if the object can't be re-instantiated due to being an unlocatable type

makePbKey(Object key)

public static byte[] makePbKey(Object key)

Converts the user's key Object into a byte[] for the MemcacheGetRequest. Because the underlying service has a length limit, we actually use the SHA1 hash of the serialized object as its key if it's not a basic type. For the basic types (that is, String, Boolean, and the fixed-point numbers), we use a human-readable representation.

Parameter
NameDescription
keyObject
Returns
TypeDescription
byte[]

hash result. For the key null, the hash is also null.

Exceptions
TypeDescription
IOException

serialize(Object value)

public static MemcacheSerialization.ValueAndFlags serialize(Object value)
Parameter
NameDescription
valueObject
Returns
TypeDescription
MemcacheSerialization.ValueAndFlags

the ValueAndFlags containing a serialized representation of the Object and the flags to hint deserialization.

Exceptions
TypeDescription
IOException

for serialization errors, normally due to a non-serializable object type