# Class MemcacheSerialization (5.0.3)

    public class MemcacheSerialization

Static serialization helpers used by MemcacheServiceImpl

This class is thread-safe.

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> MemcacheSerialization

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Fields

### USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY

    public static final String USE_THREAD_CONTEXT_CLASSLOADER_PROPERTY

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

## 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** ||
|---|---|
| **Name** | **Description** |
| `value` | `byte[]` |
| `flags` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` | the Object originally stored |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/ClassNotFoundException.html` | if the object can't be re-instantiated due to being an unlocatable type |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` | 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** ||
|---|---|
| **Name** | **Description** |
| `key` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `byte[]` | hash result. For the key `null`, the hash is also `null`. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### serialize(Object value)

    public static MemcacheSerialization.ValueAndFlags serialize(Object value)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/appengine/docs/standard/java-gen2/reference/services/bundled/latest/com.google.appengine.api.memcache.MemcacheSerialization.ValueAndFlags` | the ValueAndFlags containing a serialized representation of the Object and the flags to hint deserialization. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` | for serialization errors, normally due to a non-serializable object type |