mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05: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()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
|
|
||||||
|
// Double check.
|
||||||
|
if cachedIndex := s.getIndex(p); cachedIndex != nil {
|
||||||
|
return cachedIndex, nil
|
||||||
|
}
|
||||||
|
|
||||||
for _, c := range s.cfg.Indices {
|
for _, c := range s.cfg.Indices {
|
||||||
if c.Type == related.TypeFragments {
|
if c.Type == related.TypeFragments {
|
||||||
// This will trigger building the Pages' fragment map.
|
// This will trigger building the Pages' fragment map.
|
||||||
|
@ -219,11 +224,6 @@ func (s *RelatedDocsHandler) getOrCreateIndex(ctx context.Context, p Pages) (*re
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if cachedIndex := s.getIndex(p); cachedIndex != nil {
|
|
||||||
return cachedIndex, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
searchIndex := related.NewInvertedIndex(s.cfg)
|
searchIndex := related.NewInvertedIndex(s.cfg)
|
||||||
|
|
Loading…
Reference in a new issue