Skip to content
Bluetape4k docs1.11

Choosing binary serializers

Latest stable Based on Bluetape4k release 1.11.0

RedisBinarySerializer wraps a bluetape4k BinarySerializer as Spring Data Redis RedisSerializer<Any>.

val serializer = RedisBinarySerializer(BinarySerializers.LZ4Fory)
val encoded = serializer.serialize(order)
val decoded = serializer.deserialize(encoded) as Order

The wrapper adds no type metadata policy. Class registration, schema compatibility, and allowed types remain contracts of the selected binary serializer.

RedisBinarySerializers creates every instance lazily.

SerializerNoneGZipLZ4SnappyZstd
KryoKryoGzipKryoLZ4KryoSnappyKryoZstdKryo
ForyForyGzipForyLZ4ForySnappyForyZstdFory
JDKJdkGzipJdkLZ4JdkSnappyJdkZstdJdk

Every JDK entry is deprecated. Use Kryo or Fory for general object values.

serialize(null) returns emptyByteArray; deserialize(null) returns null. Tests repeat this contract for every binary combination.

An empty byte array can also be valid application data. If null, missing keys, and empty payloads must differ, reject null at the template boundary or use an explicit envelope. Keep key absence as a template-level outcome rather than a serializer domain value.

Choose from actual model compatibility, not generic performance claims.

  • Round-trip representative DTOs, collections, and nullable fields.
  • Test readers and writers from different application versions.
  • Verify class-name, field, and polymorphic-type changes.
  • Compare a schema-based or readable format when other languages or tools consume the values.

The 1.11.0 tests cover same-version strings, data classes, lists, and compression combinations. They do not guarantee long-term schema evolution.

JDK deserialization can expose gadget chains from classes on the application classpath. Each JDK constant points to a Kryo replacement in its @Deprecated metadata.

For existing JDK values, plan a versioned keyspace and migration window instead of suppressing warnings indefinitely. Treat values as untrusted whenever other services, tools, or compromised credentials can write them.