Skip to content

Commit

Permalink
cache: fmt.Sprintf("%x") -> hex.EncodeToString()
Browse files Browse the repository at this point in the history
  • Loading branch information
dgryski committed Oct 16, 2016
1 parent dddd742 commit 7d7349b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cache.go
Expand Up @@ -2,7 +2,7 @@ package main

import (
"crypto/sha1"
"fmt"
"encoding/hex"
"time"

"github.com/bradfitz/gomemcache/memcache"
Expand Down Expand Up @@ -43,7 +43,8 @@ type memcachedCache struct {
}

func (m *memcachedCache) get(k string) ([]byte, bool) {
hk := fmt.Sprintf("%x", sha1.Sum([]byte(k)))
key := sha1.Sum([]byte(k))
hk := hex.EncodeToString(key[:])
done := make(chan bool, 1)

var err error
Expand Down Expand Up @@ -71,6 +72,7 @@ func (m *memcachedCache) get(k string) ([]byte, bool) {
}

func (m *memcachedCache) set(k string, v []byte, expire int32) {
hk := fmt.Sprintf("%x", sha1.Sum([]byte(k)))
key := sha1.Sum([]byte(k))
hk := hex.EncodeToString(key[:])
go m.client.Set(&memcache.Item{Key: hk, Value: v, Expiration: expire})
}

0 comments on commit 7d7349b

Please sign in to comment.