Skip to content
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

Rewrite internal cache package for lcw requirements #17

Merged
merged 1 commit into from
May 3, 2020
Merged

Rewrite internal cache package for lcw requirements #17

merged 1 commit into from
May 3, 2020

Conversation

paskal
Copy link
Collaborator

@paskal paskal commented May 2, 2020

Simplify the logic, removing functions calls and storage. Stats removed as they are provided by lcw itself.

cache/cache.go Outdated Show resolved Hide resolved
cache/cache.go Outdated Show resolved Hide resolved
cache/cache.go Show resolved Hide resolved
cache/cache.go Outdated Show resolved Hide resolved
if !ok {
c.data[key] = &cacheItem{}
}
c.data[key].data = value
Copy link
Member

@umputun umputun May 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this assignment can be potentially risky if the value has some sort of mutable elements in, like a slice. Not sure if we should care about ti and perform some deep copy. Probably makes sense to see what other caches do in this case

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go-cache does nothing, gcache provides ability to set serializeFunc but it's not provided out of the box.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ristretto does nothing as well. Seems to be up to a caller not to shoot himself in a leg.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let's keep it as-is, but mention it in the readme as something user should be aware of

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#18 created to fix it.

cache/cache.go Outdated Show resolved Hide resolved
cache/cache.go Outdated Show resolved Hide resolved
@umputun umputun merged commit 5725a7a into go-pkgz:internal May 3, 2020
@paskal paskal deleted the internal-patch branch May 3, 2020 19:27
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.

None yet

2 participants