Design and trade-offs
Alright, brace yourselves, because we’re diving into the deep end of design decisions. Think of it as being handed a pristine Go environment and being asked to build a distributed cache. Simple, right? Sure, if by “simple” you mean navigating a minefield of trade-offs that could blow up your system if you take one wrong step.
Creating the project
Although the fully tested and functional version of our cache is available in this book’s GitHub repository, let’s reproduce all the steps to make our cache system:
- Creating the project directory:
mkdir spewg-cache cd spewg-cache
- Initialize the
go
module:go mod init spewg-cache
- Create the
cache.go
file:package main type CacheItem struct { Value string } type Cache struct { items map[string]CacheItem } func NewCache() *Cache { return &Cache{ items...