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

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

Issue 2435113002: LogDog: Add Storage-layer data caching. (Closed)
Patch Set: Fix byteLimit bug. Created 4 years, 1 month 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
(Empty)
1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package archive
6
7 import (
8 "github.com/luci/luci-go/common/gcloud/gs"
9 "github.com/luci/luci-go/logdog/common/storage/caching"
10
11 "golang.org/x/net/context"
12 )
13
14 // cacheSchema represents the cache schema used by this version of the tail
15 // cache. If the underlying data format changes, this value must also be
16 // updated.
17 const cacheSchema = "v1"
18
19 func getCachedLogIndexData(c context.Context, cache caching.Cache, path gs.Path) []byte {
20 itm := mkCachedLogIndexDataItem(path)
21 cache.Get(c, itm)
22 return itm.Data
23 }
24
25 func putCachedLogIndexData(c context.Context, cache caching.Cache, path gs.Path, indexData []byte) {
26 itm := mkCachedLogIndexDataItem(path)
27 itm.Data = indexData
28 cache.Put(c, 0, itm)
29 }
30
31 func mkCachedLogIndexDataItem(path gs.Path) *caching.Item {
32 return &caching.Item{
33 Schema: cacheSchema,
34 Type: "archive_log_index",
35 Key: caching.HashKey(string(path)),
36 }
37 }
OLDNEW
« no previous file with comments | « logdog/appengine/coordinator/storage_cache_test.go ('k') | logdog/common/storage/archive/storage.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698