Skip to content

Commit

Permalink
Fix sep & set visited
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejholly committed May 23, 2024
1 parent c709782 commit f39340e
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions solver/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,14 +442,16 @@ func (m *cacheKeyManager) add(d digest.Digest, s *simpleCacheMap) {
m.mu.Lock()
defer m.mu.Unlock()

s.visited = time.Now()
m.cacheMaps[d] = s

// Prune old keys once per hour. This should be minimally disruptive to
// adding new keys. Keys are build-specific, so deleting hours old keys
// should not impact newer builds.
// Prune old keys at min of once per hour. This should be minimally
// disruptive to adding new keys. Keys are build-specific, so deleting hours
// old keys should not impact newer builds.
if olderThan(m.lastPrune, m.prunePeriod) {
for k, cacheMap := range m.cacheMaps {
if olderThan(cacheMap.visited, m.pruneMaxAge) {
fmt.Println("deleting cache map key", cacheMap.visited, k, m.pruneMaxAge)
delete(m.cacheMaps, k)
}
}
Expand Down Expand Up @@ -672,20 +674,13 @@ func (r *RefIDStore) pruneLoop(ctx context.Context) {
}
}

func (r *RefIDStore) delete(_ context.Context, key string) error {
return r.db.Update(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte(r.bucketName))
return b.Delete([]byte(key))
})
}

func refIDVal(v string) []byte {
return []byte(fmt.Sprintf("%s:%d", v, time.Now().Unix()))
return []byte(fmt.Sprintf("%s@%d", v, time.Now().Unix()))
}

func parseRefIDVal(v []byte) (string, time.Time, error) {
s := string(v)
before, after, ok := strings.Cut(s, ":")
before, after, ok := strings.Cut(s, "@")
if !ok {
return before, time.Time{}, nil
}
Expand Down

0 comments on commit f39340e

Please sign in to comment.