[id='protobuf-encoding_{context}']
= Protobuf cache encoding
Protocol Buffers (Protobuf) is a lightweight binary media type for structured data.
As a cache encoding, Protobuf gives you excellent performance as well as interoperability between client applications in different programming languages for both Hot Rod and REST endpoints.

{brandname} uses a ProtoStream library to encode caches as Protobuf with the `application/x-protostream` media type.

The following example shows a Protobuf message that describes a `Person` object:

[source,json,options="nowrap",subs=attributes+]
----
include::protobuf/personalshopper.proto[]
----

[NOTE]
====
Protobuf does not support circular objects.
Use Java serialization or JBoss Marshalling to marshall circular objects.
====

[discrete]
== Interoperability

Because it is language neutral, Protobuf encoding means {brandname} can handle requests from client applications written in Java, C{plusplus}, C#, Python, Go, and more.

Protobuf also enables clients on different remote endpoints, Hot Rod or REST, to operate on the same data.
Because it uses the REST API, you can access and work with Protobuf-encoded caches through {brandname} Console.

[NOTE]
====
You cannot use {brandname} Console with any binary encoding other than `application/x-protostream`.
====

//Downstream content
ifdef::downstream[]
You should always use Protobuf cache encoding with the `application/x-protostream` media type for integration with any Red Hat technology because it allows communication between applications and services.
endif::downstream[]

[discrete]
== Queries

{brandname} needs a structured representation of data in caches for fast and reliable queries.
To search caches with the Ickle query language, you register Protobuf schema that describe your objects.

[discrete]
== Custom types

{brandname} includes an implementation of the ProtoStream API with native support for frequently used types, including `String` and `Integer`.
If you want to store custom types in your caches, use ProtoStream marshalling to generate and register serialization contexts with {brandname} so that it can marshall your objects.

[role="_additional-resources"]
.Additional resources
* link:{protostreamdocroot}[{brandname} ProtoStream API]
* link:https://developers.google.com/protocol-buffers/[developers.google.com/protocol-buffers]
