2-race-in-cache

command
v0.0.0-...-f291bb4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2019 License: MIT Imports: 3 Imported by: 0

README

Race condition in caching szenario

Given is some code to cache key-value pairs from a mock database into the main memory (to reduce access time). The code is buggy and contains a race conditition. Change the code to make this thread safe.

Note: that golang's map are not entirely thread safe. Multiple readers are fine, but multiple writers are not.

Test your solution

Use the following command to test for race conditions and correct functionality:

go test -race

Correct solution: No output = solution correct:

$ go test -race

Incorrect solution:

==================
WARNING: DATA RACE
Write by goroutine 7:
...
==================
Found 3 data race(s)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL