-
Couldn't load subscription status.
- Fork 6
Remove dependency on external cache package #823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
server/cache.go
Outdated
| } | ||
|
|
||
| // Cache interface | ||
| type CacheInterface interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: rename to cache
It seems unnecessary to have interface in the name. cache is the interface and SimpleCache the implementation.
server/cache.go
Outdated
| } | ||
|
|
||
| // retrieveFromCache safely retrieves a value from a named cache | ||
| func retrieveFromCache( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: make the retrieval generic
Given the design of the simple cache it looks like we need call retrieveFromCache then do a type assertion when ever we want to get something. We could make this a generic retrival.
server/cache_test.go
Outdated
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| type testStruct struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: make this local the test its used in
server/cache_test.go
Outdated
| B string | ||
| } | ||
|
|
||
| func TestSetGetDelete(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: is there a reason we are testing multiple things in the same test opposed to just the method? For exampe,
func TestNewSimpleCache_SetDefault(t *testing.T) {
var tests = []struct {
name string
given given
exp expected
}{
{
name: "no_expiration",
},
{
name: "default_expiration",
},
{
name: "set_multiple_types",
},
...
server/cache_test.go
Outdated
| assert.False(t, found, "Expected key %q to be deleted", key) | ||
| } | ||
|
|
||
| func TestExpiration(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: make this part of the SetDefault tests
the tests don really align with the prod code
No description provided.