Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2205)

Unified Diff: filter/dscache/dscache.go

Issue 1292913002: Split off serialization and key functions to their own packages. (Closed) Base URL: https://github.com/luci/gae.git@make_queries_better
Patch Set: rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | filter/dscache/dscache_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filter/dscache/dscache.go
diff --git a/filter/dscache/dscache.go b/filter/dscache/dscache.go
index 9d967b8b7c53dcbe6f2579bc18e317876bb3fbc2..dd52c0ba69a2d7cb20b2e8fb3dccaba9bb1aa6f8 100644
--- a/filter/dscache/dscache.go
+++ b/filter/dscache/dscache.go
@@ -12,6 +12,7 @@ import (
"time"
"github.com/luci/gae/service/datastore"
+ "github.com/luci/gae/service/datastore/serialize"
)
var (
@@ -105,11 +106,8 @@ func MakeMemcacheKey(shard int, k datastore.Key) string {
}
func HashKey(k datastore.Key) string {
- // errs can't happen, since we're using a byte buffer.
+ dgst := sha1.Sum(serialize.ToBytes(k))
buf := bytes.Buffer{}
- _ = datastore.WriteKey(&buf, datastore.WithoutContext, k)
- dgst := sha1.Sum(buf.Bytes())
- buf.Reset()
enc := base64.NewEncoder(base64.StdEncoding, &buf)
_, _ = enc.Write(dgst[:])
enc.Close()
« no previous file with comments | « no previous file | filter/dscache/dscache_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698