mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-24 02:22:04 +00:00
page: Move the cache double check right after the lock
This commit is contained in:
parent
fa2d7adf10
commit
586fea0de6
1 changed files with 5 additions and 5 deletions
|
@ -198,6 +198,11 @@ func (s *RelatedDocsHandler) getOrCreateIndex(ctx context.Context, p Pages) (*re
|
|||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
// Double check.
|
||||
if cachedIndex := s.getIndex(p); cachedIndex != nil {
|
||||
return cachedIndex, nil
|
||||
}
|
||||
|
||||
for _, c := range s.cfg.Indices {
|
||||
if c.Type == related.TypeFragments {
|
||||
// This will trigger building the Pages' fragment map.
|
||||
|
@ -219,11 +224,6 @@ func (s *RelatedDocsHandler) getOrCreateIndex(ctx context.Context, p Pages) (*re
|
|||
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if cachedIndex := s.getIndex(p); cachedIndex != nil {
|
||||
return cachedIndex, nil
|
||||
}
|
||||
|
||||
searchIndex := related.NewInvertedIndex(s.cfg)
|
||||
|
|
Loading…
Reference in a new issue