eko / gocache

☔️ A complete Go cache library that brings you multiple ways of managing your caches
https://vincent.composieux.fr/article/i-wrote-gocache-a-complete-and-extensible-go-cache-library/
MIT License
2.42k stars 192 forks source link

Fix for applyOptionsWithDefault not keeping unmodified options #169

Closed sgtsquiggs closed 1 year ago

sgtsquiggs commented 1 year ago

I assume this was just an oversight. I was expecting that any specified options would override defaults, but unspecified options would still use the default options.

IE:

// Given
defaultOptions := &Options{
    expiration: 25 * time.Second,
}

// When
options := applyOptionsWithDefault(defaultOptions, WithCost(7))

// Then
assert.Equal(t, int64(7), options.cost)
assert.Equal(t, 25*time.Second, options.expiration)
sgtsquiggs commented 1 year ago

fixes #168

sgtsquiggs commented 1 year ago

failures seem unrelated

eko commented 1 year ago

Yes, I will take a look later. Thank you for this PR!