Skip to content

Commit

Permalink
Merge pull request redis#76 from go-redis/fix/hash-slot-unexport
Browse files Browse the repository at this point in the history
Unexport HashSlot.
  • Loading branch information
vmihailenco committed Mar 30, 2015
2 parents 381a637 + 36a06ec commit d363cc7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (c *ClusterClient) process(cmd Cmder) {

c.reloadIfDue()

hashSlot := HashSlot(cmd.clusterKey())
hashSlot := hashSlot(cmd.clusterKey())

c.cachemx.RLock()
defer c.cachemx.RUnlock()
Expand Down Expand Up @@ -288,9 +288,9 @@ func (opt *ClusterOptions) clientOptions() *Options {

const hashSlots = 16384

// HashSlot returns a consistent slot number between 0 and 16383
// for any given string key
func HashSlot(key string) int {
// hashSlot returns a consistent slot number between 0 and 16383
// for any given string key.
func hashSlot(key string) int {
if s := strings.IndexByte(key, '{'); s > -1 {
if e := strings.IndexByte(key[s+1:], '}'); e > 0 {
key = key[s+1 : s+e+1]
Expand Down
4 changes: 4 additions & 0 deletions export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ package redis
func (c *baseClient) Pool() pool {
return c.connPool
}

func HashSlot(key string) int {
return hashSlot(key)
}

0 comments on commit d363cc7

Please sign in to comment.