

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: State
incomplete
2: PokeAPI
incomplete
3: Cache Add/Get
incomplete
4: Cache Reaping
incomplete
5: Cache Integration
incomplete
6: Explore
incomplete
7: Catch
incomplete
8: Inspect
incomplete
This lesson's interactive features are locked, please to keep using them
A cache stores data so that future requests for that data can be served faster. We'll use one to keep PokeAPI responses in memory. No need to make the same network request twice!
First, we need a way to store and retrieve entries. I used a Cache struct with a map[string][]byte: the key identifies the data, and the value holds the raw bytes. The cache doesn't need to know anything about Pokemon or JSON.
We'll add expiration and connect the cache to the PokeAPI in the next lessons. For now, map and mapb should work as before.
Run and submit the CLI tests from the root of the repo.