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

add cache package #217

Merged
merged 1 commit into from
Aug 14, 2020
Merged

add cache package #217

merged 1 commit into from
Aug 14, 2020

Conversation

Teelevision
Copy link
Contributor

I extracted the cache from one of our services, because I thought this was already a pretty general solution that we could make use of in other places as well.

I'm a bit unsure about the naming. Because the package is already called cache I tried to avoid using cache, like cache.Cache and cache.RedisCache. So a struct that needs a cache could look like this:

type NameMap struct {
    Names cache.Strings
}

And initialisation like this:

nm.Names = cache.InMemory()
// or
nm.Names = cache.InRedis(redisClient, "prefix")

pkg/cache/cache.go Outdated Show resolved Hide resolved
pkg/cache/cache.go Outdated Show resolved Hide resolved
pkg/cache/cache.go Outdated Show resolved Hide resolved
pkg/cache/cache.go Outdated Show resolved Hide resolved
@Teelevision
Copy link
Contributor Author

I added a test suite.

Copy link
Contributor

@daemonfire300 daemonfire300 left a comment

Choose a reason for hiding this comment

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

Not sure if two exposed errors are enough but I couldn't think of more errors that are not already handled by handling contexts errors in general. So:

LGTM.

@daemonfire300 daemonfire300 merged commit 6506a6d into master Aug 14, 2020
@daemonfire300 daemonfire300 deleted the cache branch August 14, 2020 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants