aboutsummaryrefslogtreecommitdiffhomepage
path: root/cache
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-08-07 10:40:54 +0200
committerBjørn Erik Pedersen <[email protected]>2024-08-09 17:18:37 +0200
commit33c0938cd50dd3409f8e94878b97d789cc328f23 (patch)
treefc4cc45265b86746aa37bc3ab4445724d22a98f2 /cache
parent0c3a1c7288032401327a9c4d7044e297bf3f7da6 (diff)
downloadhugo-33c0938cd50dd3409f8e94878b97d789cc328f23.tar.gz
hugo-33c0938cd50dd3409f8e94878b97d789cc328f23.zip
Add build time math rendering
While very useful on its own (and combined with the passthrough render hooks), this also serves as a proof of concept of using WASI (WebAssembly System Interface) modules in Hugo. This will be marked _experimental_ in the documentation. Not because it will be removed or changed in a dramatic way, but we need to think a little more how to best set up/configure similar services, define where these WASM files gets stored, maybe we can allow user provided WASM files plugins via Hugo Modules mounts etc. See these issues for more context: * https://github.com/gohugoio/hugo/issues/12736 * https://github.com/gohugoio/hugo/issues/12737 See #11927
Diffstat (limited to 'cache')
-rw-r--r--cache/filecache/filecache_config.go12
-rw-r--r--cache/filecache/filecache_config_test.go6
2 files changed, 14 insertions, 4 deletions
diff --git a/cache/filecache/filecache_config.go b/cache/filecache/filecache_config.go
index 6a2b5f3e3..a71ddb474 100644
--- a/cache/filecache/filecache_config.go
+++ b/cache/filecache/filecache_config.go
@@ -46,6 +46,7 @@ const (
CacheKeyAssets = "assets"
CacheKeyModules = "modules"
CacheKeyGetResource = "getresource"
+ CacheKeyMisc = "misc"
)
type Configs map[string]FileCacheConfig
@@ -70,10 +71,14 @@ var defaultCacheConfigs = Configs{
MaxAge: -1,
Dir: resourcesGenDir,
},
- CacheKeyGetResource: FileCacheConfig{
+ CacheKeyGetResource: {
MaxAge: -1, // Never expire
Dir: cacheDirProject,
},
+ CacheKeyMisc: {
+ MaxAge: -1,
+ Dir: cacheDirProject,
+ },
}
type FileCacheConfig struct {
@@ -120,6 +125,11 @@ func (f Caches) AssetsCache() *Cache {
return f[CacheKeyAssets]
}
+// MiscCache gets the file cache for miscellaneous stuff.
+func (f Caches) MiscCache() *Cache {
+ return f[CacheKeyMisc]
+}
+
// GetResourceCache gets the file cache for remote resources.
func (f Caches) GetResourceCache() *Cache {
return f[CacheKeyGetResource]
diff --git a/cache/filecache/filecache_config_test.go b/cache/filecache/filecache_config_test.go
index f93c7060e..c6d346dfc 100644
--- a/cache/filecache/filecache_config_test.go
+++ b/cache/filecache/filecache_config_test.go
@@ -59,7 +59,7 @@ dir = "/path/to/c4"
c.Assert(err, qt.IsNil)
fs := afero.NewMemMapFs()
decoded := testconfig.GetTestConfigs(fs, cfg).Base.Caches
- c.Assert(len(decoded), qt.Equals, 6)
+ c.Assert(len(decoded), qt.Equals, 7)
c2 := decoded["getcsv"]
c.Assert(c2.MaxAge.String(), qt.Equals, "11h0m0s")
@@ -106,7 +106,7 @@ dir = "/path/to/c4"
c.Assert(err, qt.IsNil)
fs := afero.NewMemMapFs()
decoded := testconfig.GetTestConfigs(fs, cfg).Base.Caches
- c.Assert(len(decoded), qt.Equals, 6)
+ c.Assert(len(decoded), qt.Equals, 7)
for _, v := range decoded {
c.Assert(v.MaxAge, qt.Equals, time.Duration(0))
@@ -129,7 +129,7 @@ func TestDecodeConfigDefault(t *testing.T) {
fs := afero.NewMemMapFs()
decoded := testconfig.GetTestConfigs(fs, cfg).Base.Caches
- c.Assert(len(decoded), qt.Equals, 6)
+ c.Assert(len(decoded), qt.Equals, 7)
imgConfig := decoded[filecache.CacheKeyImages]
jsonConfig := decoded[filecache.CacheKeyGetJSON]