Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

work in progress: Mem cache and dependency res. improvements etc. #9334

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"autoHide.autoHidePanel": false
}
37 changes: 0 additions & 37 deletions bench.sh

This file was deleted.

12 changes: 0 additions & 12 deletions benchSite.sh

This file was deleted.

2 changes: 1 addition & 1 deletion benchbep.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
gobench -package=./hugolib -bench="BenchmarkSiteNew/Deep_content_tree"
gobench --package ./hugolib --bench "BenchmarkSiteNew/Regular_Deep" -base v0.89.4
1 change: 0 additions & 1 deletion bepdock.sh

This file was deleted.

3 changes: 2 additions & 1 deletion cache/filecache/filecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package filecache

import (
"bytes"
"context"
"errors"
"io"
"io/ioutil"
Expand Down Expand Up @@ -163,7 +164,7 @@ func (c *Cache) ReadOrCreate(id string,
// GetOrCreate tries to get the file with the given id from cache. If not found or expired, create will
// be invoked and the result cached.
// This method is protected by a named lock using the given id as identifier.
func (c *Cache) GetOrCreate(id string, create func() (io.ReadCloser, error)) (ItemInfo, io.ReadCloser, error) {
func (c *Cache) GetOrCreate(ctx context.Context, id string, create func() (io.ReadCloser, error)) (ItemInfo, io.ReadCloser, error) {
id = cleanID(id)

c.nlocker.Lock(id)
Expand Down
7 changes: 4 additions & 3 deletions cache/filecache/filecache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package filecache

import (
"context"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -134,7 +135,7 @@ dir = ":cacheDir/c"

for _, ca := range []*Cache{caches.ImageCache(), caches.AssetsCache(), caches.GetJSONCache(), caches.GetCSVCache()} {
for i := 0; i < 2; i++ {
info, r, err := ca.GetOrCreate("a", rf("abc"))
info, r, err := ca.GetOrCreate(context.TODO(), "a", rf("abc"))
c.Assert(err, qt.IsNil)
c.Assert(r, qt.Not(qt.IsNil))
c.Assert(info.Name, qt.Equals, "a")
Expand All @@ -152,7 +153,7 @@ dir = ":cacheDir/c"
c.Assert(err, qt.IsNil)
c.Assert(string(b), qt.Equals, "abc")

_, r, err = ca.GetOrCreate("a", rf("bcd"))
_, r, err = ca.GetOrCreate(context.TODO(), "a", rf("bcd"))
c.Assert(err, qt.IsNil)
b, _ = ioutil.ReadAll(r)
r.Close()
Expand Down Expand Up @@ -229,7 +230,7 @@ dir = "/cache/c"
ca := caches.Get(cacheName)
c.Assert(ca, qt.Not(qt.IsNil))
filename, data := filenameData(i)
_, r, err := ca.GetOrCreate(filename, func() (io.ReadCloser, error) {
_, r, err := ca.GetOrCreate(context.TODO(), filename, func() (io.ReadCloser, error) {
return hugio.ToReadCloser(strings.NewReader(data)), nil
})
c.Assert(err, qt.IsNil)
Expand Down
Loading