-
Notifications
You must be signed in to change notification settings - Fork 0
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
Memcached clusters #33
base: main
Are you sure you want to change the base?
Conversation
yep, the cache topology tester looks right to me. good work |
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.
This looks great! Left a couple of very minor thoughts on naming :)
"github.com/bradfitz/gomemcache/memcache" | ||
) | ||
|
||
type ICacheService 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.
A common pattern I've seen naming-wise is to name the interface CacheService
, to have the standard/obvious implementation be private and called cacheService
, and to have NewCacheService
return a CacheService
(i.e. the interface). This means that you don't need the ugly I
-prefix, and that the caller can only access the publicly declared interface functionality rather than relying on internal implementation details.
log.Println(clusterType) | ||
} | ||
|
||
func checkIfSharded(router ICacheService, nodes map[string]ICacheService) (string, error) { |
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.
From the name checkIfSharded
, I would expect this to probably return a boolean, and it's not super clear what "not sharded" (i.e. false) would mean.
I'd maybe call this checkMode
(to imply "there are multiple modes it may return") or detectShardedOrReplicated
(to be clear what the universe of return values is).
Use the set and get commands again to understand the behaviour of this mcrouter configuration. How does the behaviour differ from the replicated cluster?
printf "get mykey\r\n" | nc localhost 11211
- this is the router, returns dataprintf "get mykey\r\n" | nc localhost 11212
- replica, returns same dataprintf "get mykey\r\n" | nc localhost 11213
- replica, returns same dataprintf "get mykey\r\n" | nc localhost 11214
- replica, returns same dataprintf "get mykey\r\n" | nc localhost 11211
- this is the router, returns dataprintf "get mykey\r\n" | nc localhost 11212
- returns data, as the router stored it in this instanceprintf "get mykey\r\n" | nc localhost 11213
- doesn't return dataprintf "get mykey\r\n" | nc localhost 11214
- doesn't return data