O'Reilly logo

Elixir Cookbook by Paulo A Pereira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a key/value store with a map

In Elixir, map is the tool to use when we need a very simple key/value store. A map is a data type for associative collections (or dictionaries).

The Map module is an implementation of the Dict API. The following is the Dict documentation page:

Creating a key/value store with a map

Getting ready

Start a new IEx session in your console.

How to do it…

In this recipe, we will create an in-memory database of the English Premier League, where we will keep the current points, number of played games, and the club name. We will be creating a map to hold the league and a map for each team. This will be a map of maps! The steps are as follows:

  1. We will create the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required