Skip to content

Commit

Permalink
Add a little delay to the database call.
Browse files Browse the repository at this point in the history
This additional slowdown offers the change to optimizing the locking code.
  • Loading branch information
benprew committed Aug 14, 2020
1 parent 2d3d847 commit 53b9b7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions 2-race-in-cache/mockdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

package main

import "time"

// MockDB used to simulate a database model
type MockDB struct{}

// Get only returns an empty string, as this is only for demonstration purposes
func (*MockDB) Get(key string) (string, error) {
d, _ := time.ParseDuration("20ms")
time.Sleep(d)
return "", nil
}

Expand Down
2 changes: 1 addition & 1 deletion 2-race-in-cache/mockserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

const (
cycles = 3
cycles = 15
callsPerCycle = 100
)

Expand Down

0 comments on commit 53b9b7b

Please sign in to comment.