about summary refs log tree commit diff
path: root/tools/nixery/server/builder/cache.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-10-02T16·48+0100
committerVincent Ambo <github@tazj.in>2019-10-03T12·21+0100
commit0698d7f2aafc62c1ef6fca172668310727fdaef2 (patch)
tree08dff540911f22ca640eac636952d19467ccaf5f /tools/nixery/server/builder/cache.go
parent64fca61ea1d898c01893f56f0e03913f36468f5d (diff)
chore(server): Remove "layer seen" cache
This cache is no longer required as it is implicit because the layer
cache (mapping store path hashes to layer hashes) implies that a layer
has been seen.
Diffstat (limited to 'tools/nixery/server/builder/cache.go')
-rw-r--r--tools/nixery/server/builder/cache.go34
1 files changed, 5 insertions, 29 deletions
diff --git a/tools/nixery/server/builder/cache.go b/tools/nixery/server/builder/cache.go
index 254f32d8306d..1ed87b40a130 100644
--- a/tools/nixery/server/builder/cache.go
+++ b/tools/nixery/server/builder/cache.go
@@ -25,8 +25,6 @@ import (
 	"cloud.google.com/go/storage"
 )
 
-type void struct{}
-
 type Build struct {
 	SHA256 string `json:"sha256"`
 	MD5    string `json:"md5"`
@@ -39,40 +37,18 @@ type LocalCache struct {
 	mmtx   sync.RWMutex
 	mcache map[string]string
 
-	// Layer (tarball) cache
+	// Layer cache
 	lmtx   sync.RWMutex
-	lcache map[string]void
-
-	// Layer (build) cache
-	bmtx   sync.RWMutex
-	bcache map[string]Build
+	lcache map[string]Build
 }
 
 func NewCache() LocalCache {
 	return LocalCache{
 		mcache: make(map[string]string),
-		lcache: make(map[string]void),
-		bcache: make(map[string]Build),
+		lcache: make(map[string]Build),
 	}
 }
 
-// Has this layer hash already been seen by this Nixery instance? If
-// yes, we can skip upload checking and such because it has already
-// been done.
-func (c *LocalCache) hasSeenLayer(hash string) bool {
-	c.lmtx.RLock()
-	defer c.lmtx.RUnlock()
-	_, seen := c.lcache[hash]
-	return seen
-}
-
-// Layer has now been seen and should be stored.
-func (c *LocalCache) sawLayer(hash string) {
-	c.lmtx.Lock()
-	defer c.lmtx.Unlock()
-	c.lcache[hash] = void{}
-}
-
 // Retrieve a cached manifest if the build is cacheable and it exists.
 func (c *LocalCache) manifestFromLocalCache(key string) (string, bool) {
 	c.mmtx.RLock()
@@ -97,7 +73,7 @@ func (c *LocalCache) localCacheManifest(key, path string) {
 // Retrieve a cached build from the local cache.
 func (c *LocalCache) buildFromLocalCache(key string) (*Build, bool) {
 	c.bmtx.RLock()
-	b, ok := c.bcache[key]
+	b, ok := c.lcache[key]
 	c.bmtx.RUnlock()
 
 	return &b, ok
@@ -106,7 +82,7 @@ func (c *LocalCache) buildFromLocalCache(key string) (*Build, bool) {
 // Add a build result to the local cache.
 func (c *LocalCache) localCacheBuild(key string, b Build) {
 	c.bmtx.Lock()
-	c.bcache[key] = b
+	c.lcache[key] = b
 	c.bmtx.Unlock()
 }