loong / go-concurrency-exercises

Hands on exercises with real-life examples to study and practice Go concurrency patterns. Test-cases are provided to verify your answers.
Other
1.17k stars 401 forks source link

Race in cache fix #8

Closed rationull closed 6 years ago

rationull commented 6 years ago

I noticed that exercise 2 "race-in-cache" doesn't actually write values into the KeyStoreCache.cache map, which means the cache size limiting doesn't work and also eliminates some of the race conditions that should be present.

Was this intentional for some reason? Figured I'd submit the trivial PR in case it's not.

Also added a test case for this exercise that will fail if the race conditions are removed but the cache map or pages list aren't updated correctly.

loong commented 6 years ago

Hi @rationull. Thanks so much for the PR. I am traveling through Myanmar right now and only have limited access (no laptop with me and bad internet), so can't fully test your PR. However, it looks good to me, so I'll just trust you and merge. =)

rationull commented 6 years ago

Thanks @mindworker for publishing this repo with some fun exercises -- happy to help. Best wishes on your travels!