Multimap Caches with the Go Client

Tip
The source code for this tutorial is available on GitHub.

This tutorial demonstrates how to use multimap caches with the Go Hot Rod client to associate multiple values with a single key.

Prerequisites

  • A running Infinispan server.

  • Go 1.25 or later.

Running the Example

go run ./multimap

Code Walkthrough

Creating a Multimap Handle

mm := client.Multimap("test")

Storing Multiple Values

Each Put call adds a value under the given key without replacing existing values.

mm.Put(ctx, []byte("2016"), []byte("Rosita"))
mm.Put(ctx, []byte("2016"), []byte("Guillermo"))

Retrieving All Values

Get returns all values associated with a key.

values, err := mm.Get(ctx, []byte("2016"))

Expected Output

People born in 2016:
  Rosita
  Guillermo
  Patricia
  Silvia
Total entries: 7
Cache removed.