[id='encoding-caches-protostream_{context}']
= Encoding caches as ProtoStream
Configure {brandname} to use the ProtoStream library to store cache entries as Protocol Buffers (Protobuf).

.Procedure

* Specify the `application/x-protostream` media type for keys and values.

.Declarative
[source,xml,options="nowrap",subs=attributes+,role="primary"]
----
include::xml/encoding_protostream.xml[]
----

.Programmatic
[source,java,options="nowrap",subs=attributes+,role="secondary"]
----
include::code_examples/ConfigurationBuilderCacheEncoding.java[]
----

Alternatively you can use the same encoding for keys and values:

.Declarative
[source,xml,options="nowrap",subs=attributes+,role="primary"]
----
<encoding media-type="application/x-protostream"/>
----

.Programmatic
[source,java,options="nowrap",subs=attributes+,role="secondary"]
----
.encoding().mediaType("application/x-protostream");
----

[role="_additional-resources"]
.Additional resources
* link:../../configuration-schema/index.html[{brandname} Schema Reference]
* link:../../apidocs/org/infinispan/configuration/cache/ConfigurationBuilder.html[org.infinispan.configuration.cache.ConfigurationBuilder]
