| OLD | NEW |
| (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 } |
| OLD | NEW |