Skip to content

Conversation

@Sneagan
Copy link
Collaborator

@Sneagan Sneagan commented Aug 13, 2025

No description provided.

@Sneagan Sneagan marked this pull request as ready for review October 8, 2025 03:11
@Sneagan Sneagan requested a review from clD11 October 8, 2025 03:11
server/cache.go Outdated
}

// Cache interface
type CacheInterface interface {
Copy link
Collaborator

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(
Copy link
Collaborator

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.

"github.com/stretchr/testify/require"
)

type testStruct struct {
Copy link
Collaborator

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

B string
}

func TestSetGetDelete(t *testing.T) {
Copy link
Collaborator

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",
		},
		
		...

assert.False(t, found, "Expected key %q to be deleted", key)
}

func TestExpiration(t *testing.T) {
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants