Skip to content

Commit

Permalink
Revived NewCache
Browse files Browse the repository at this point in the history
  • Loading branch information
noborus committed Feb 26, 2023
1 parent 38c4e42 commit 8721f70
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions oviewer/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ type chunk struct {

// NewDocument returns Document.
func NewDocument() (*Document, error) {
cache, err := lru.New(1024)
if err != nil {
return nil, err
}
m := &Document{
eofCh: make(chan struct{}),
followCh: make(chan struct{}),
Expand All @@ -149,7 +145,9 @@ func NewDocument() (*Document, error) {
chunks: []*chunk{
NewChunk(0),
},
cache: cache,
}
if err := m.NewCache(); err != nil {
return nil, err
}
return m, nil
}
Expand All @@ -161,6 +159,16 @@ func NewChunk(start int64) *chunk {
}
}

// NewCache creates a new cache.
func (m *Document) NewCache() error {
cache, err := lru.New(1024)
if err != nil {
return err
}
m.cache = cache
return nil
}

// OpenDocument opens a file and returns a Document.
func OpenDocument(fileName string) (*Document, error) {
fi, err := os.Stat(fileName)
Expand Down

0 comments on commit 8721f70

Please sign in to comment.