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

Side by Side Diff: logdog/common/storage/bigtable/cache.go

Issue 2611253005: Fix BigTable multi-entry row cached Tail. (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package bigtable 5 package bigtable
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/binary" 9 "encoding/binary"
10 "time" 10 "time"
(...skipping 29 matching lines...) Expand all
40 v, err := binary.ReadVarint(bytes.NewReader(itm.Data)) 40 v, err := binary.ReadVarint(bytes.NewReader(itm.Data))
41 if err != nil { 41 if err != nil {
42 log.Fields{ 42 log.Fields{
43 log.ErrorKey: err, 43 log.ErrorKey: err,
44 "project": project, 44 "project": project,
45 "path": path, 45 "path": path,
46 }.Warningf(c, "Could not decode last tail cache.") 46 }.Warningf(c, "Could not decode last tail cache.")
47 return 0 47 return 0
48 } 48 }
49 49
50 log.Fields{
51 "index": v,
52 }.Infof(c, "Using cached tail index.")
50 return v 53 return v
51 } 54 }
52 55
53 func putLastTailIndex(c context.Context, cache caching.Cache, project config.Pro jectName, path types.StreamPath, v int64) { 56 func putLastTailIndex(c context.Context, cache caching.Cache, project config.Pro jectName, path types.StreamPath, v int64) {
54 buf := make([]byte, binary.MaxVarintLen64) 57 buf := make([]byte, binary.MaxVarintLen64)
55 buf = buf[:binary.PutVarint(buf, v)] 58 buf = buf[:binary.PutVarint(buf, v)]
56 59
57 itm := mkLastTailItem(project, path) 60 itm := mkLastTailItem(project, path)
58 itm.Data = buf 61 itm.Data = buf
59 cache.Put(c, lastTailIndexCacheDuration, itm) 62 cache.Put(c, lastTailIndexCacheDuration, itm)
60 } 63 }
61 64
62 func mkLastTailItem(project config.ProjectName, path types.StreamPath) *caching. Item { 65 func mkLastTailItem(project config.ProjectName, path types.StreamPath) *caching. Item {
63 return &caching.Item{ 66 return &caching.Item{
64 Schema: cacheSchema, 67 Schema: cacheSchema,
65 Type: "bt_tail_idx", 68 Type: "bt_tail_idx",
66 Key: caching.HashKey(string(project), string(path)), 69 Key: caching.HashKey(string(project), string(path)),
67 } 70 }
68 } 71 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698