# MemcachedCacheEntry (Apache HttpComponents Client 4.5.14 API)
Date: 2022-11-30

org.apache.http.impl.client.cache.memcached

## Interface MemcachedCacheEntry

All Known Implementing Classes:
  MemcachedCacheEntryImpl

    public interface MemcachedCacheEntry

Provides for serialization and deserialization of higher-level `HttpCacheEntry` objects into byte arrays suitable for storage in memcached. Clients wishing to change the serialization mechanism from the provided defaults should implement this interface as well as `MemcachedCacheEntryFactory`.

### Method Summary

Methods
`HttpCacheEntry` `getHttpCacheEntry()` Returns the `HttpCacheEntry` associated with this entry.
`String` `getStorageKey()` Returns the storage key associated with this entry.
`void` `set(byte[] bytes)` Given a serialized representation of a `MemcachedCacheEntry`, attempt to reconstitute the storage key and `HttpCacheEntry` represented therein.
`byte[]` `toByteArray()` Returns a serialized representation of the current cache entry.

### Method Detail

#### toByteArray

    byte[] toByteArray()

Returns a serialized representation of the current cache entry.

#### getStorageKey

    String getStorageKey()

Returns the storage key associated with this entry. May return `null` if this is an "unset" instance waiting to be `set(byte[])` with a serialized representation.

#### getHttpCacheEntry

    HttpCacheEntry getHttpCacheEntry()

Returns the `HttpCacheEntry` associated with this entry. May return `null` if this is an "unset" instance waiting to be `set(byte[])` with a serialized representation.

#### set

    void set(byte[] bytes)

Given a serialized representation of a `MemcachedCacheEntry`, attempt to reconstitute the storage key and `HttpCacheEntry` represented therein. After a successful call to this method, this object should return updated (as appropriate) values for `getStorageKey()` and `getHttpCacheEntry()`. This should be viewed as an atomic operation on the `MemcachedCacheEntry`.

Parameters:
  `bytes` - serialized representation
Throws:
  `MemcachedSerializationException` - if deserialization fails. In this case, the prior values for {`getStorageKey()` and `getHttpCacheEntry()` should remain unchanged.