Skip to content

Commit

Permalink
added debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed May 26, 2023
1 parent 06fa539 commit 196d957
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions cache/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,9 @@ func (s *service) OpenURL(ctx context.Context, URL string, options ...storage.Op
cacheURL := strings.Replace(URL, s.scheme, mem.Scheme, 1)

reader, err := s.Service.OpenURL(ctx, cacheURL, options...)
fmt.Printf("loaded from cache: %v, %v\n", err, cacheURL)
if err == nil {
return reader, err
}
fmt.Printf("fallback to: %v, %v\n", err, URL)
return s.Service.OpenURL(ctx, URL, options...)
}

Expand Down Expand Up @@ -168,9 +166,6 @@ func (s *service) reloadIfNeeded(ctx context.Context) {

func (s *service) reloadCache(ctx context.Context) error {
cacheObject, _ := s.Service.Object(ctx, s.cacheURL, option.NewObjectKind(true))
if cacheObject != nil {
fmt.Printf("checking cache :%v %v\n", cacheObject.URL(), cacheObject.ModTime())
}
var cache *Cache
var err error
if s.shallRebuildCache(cacheObject) {
Expand Down Expand Up @@ -200,17 +195,13 @@ func (s *service) reloadCache(ctx context.Context) error {
defer func() {
s.logger.Logf("loaded cache %v after %s prev:%v: curr:%v\n", s.cacheURL, time.Since(started), prevMod, cacheObject.ModTime())
}()
startTime := time.Now()
cache, err = s.loadCache(ctx)
if err != nil {
return err
}
fmt.Printf("loaded cache after: %s\n", time.Now().Sub(startTime))
s.syncCache(ctx, cache)
mod := cacheObject.ModTime()
s.modified = &mod
fmt.Printf("sync cache after: %s\n", time.Now().Sub(startTime))

return err
}

Expand All @@ -236,7 +227,6 @@ func (s *service) syncCache(ctx context.Context, cache *Cache) {
}
}
func (s *service) build(ctx context.Context) (*Cache, error) {
fmt.Printf("rebuilding cache\n")
var opts []storage.Option
if s.exclusion != nil {
opts = append(opts, s.exclusion)
Expand Down

0 comments on commit 196d957

Please sign in to comment.