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

Unified Diff: logdog/common/storage/archive/cache.go

Issue 2435113002: LogDog: Add Storage-layer data caching. (Closed)
Patch Set: Fix byteLimit bug. Created 4 years, 2 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 | « logdog/appengine/coordinator/storage_cache_test.go ('k') | logdog/common/storage/archive/storage.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/common/storage/archive/cache.go
diff --git a/logdog/common/storage/archive/cache.go b/logdog/common/storage/archive/cache.go
new file mode 100644
index 0000000000000000000000000000000000000000..3499f406d7ef63fd1412b1b2ca1c48b2486b2bf8
--- /dev/null
+++ b/logdog/common/storage/archive/cache.go
@@ -0,0 +1,37 @@
+// Copyright 2016 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package archive
+
+import (
+ "github.com/luci/luci-go/common/gcloud/gs"
+ "github.com/luci/luci-go/logdog/common/storage/caching"
+
+ "golang.org/x/net/context"
+)
+
+// cacheSchema represents the cache schema used by this version of the tail
+// cache. If the underlying data format changes, this value must also be
+// updated.
+const cacheSchema = "v1"
+
+func getCachedLogIndexData(c context.Context, cache caching.Cache, path gs.Path) []byte {
+ itm := mkCachedLogIndexDataItem(path)
+ cache.Get(c, itm)
+ return itm.Data
+}
+
+func putCachedLogIndexData(c context.Context, cache caching.Cache, path gs.Path, indexData []byte) {
+ itm := mkCachedLogIndexDataItem(path)
+ itm.Data = indexData
+ cache.Put(c, 0, itm)
+}
+
+func mkCachedLogIndexDataItem(path gs.Path) *caching.Item {
+ return &caching.Item{
+ Schema: cacheSchema,
+ Type: "archive_log_index",
+ Key: caching.HashKey(string(path)),
+ }
+}
« 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