<pre class="prettyprint"><code class="language-scala">import scredis.serialization._

implicit object PersonWriter extends Writer[Person] {
  private val utf16StringWriter = new StringWriter(&quot;UTF-16&quot;)
  
  override def writeImpl(person: Person): Array[Byte] = {
    utf16StringWriter.write(s&quot;${person.name}:${person.age}&quot;)
  }
}

implicit object PersonReader extends Reader[Person] {
  val utf16StringReader = new StringReader(&quot;UTF-16&quot;)
  
  override def readImpl(bytes: Array[Byte]