benbrandt opened issue #10638:
Feature
wasmtime::Config::cache_configfor loading aCacheConfigfrom a struct instead of a file.Benefit
Right now, in order to use the cache, you have to provide a path to a file with the needed configuration.
However, there are cases where the wasmtime is embedded, rather than the CLI, where the cache is still helpful. It would be more convenient to create the configuration programmatically rather than loaded from a file, to allow the application to determine the cache setup based on its own configuration.
Implementation
Expose
wasmtime_cache::CacheConfigfromwasmtimeAdd setters for
wasmtime_cache::CacheConfigso individual fields can be configured.let mut cache_config = wasmtime_cache::CacheConfig::default(); cache_config.with_directory("/path/to/cache");
- Add
cache_configmethod to set this config on thewasmtime::Configlet mut config = wasmtime::Config::default(); config.cache_config(cache_config);Alternatives
Based on the implementation for the method to load from a file, this seems like a straightforward way to allow for a wasmtime user to create their own cache.
If there are other ideas, we could explore those instead.
benbrandt commented on issue #10638:
I forgot to mention, but I am open to doing the implementation (with any necessary pointers), but wanted to get feedback on the idea before submitting the PR
alexcrichton commented on issue #10638:
I think this'd be a great idea to have, thanks for filing an issue and working on this!
The only thing I'd suggest is that we wouldn't want users to have to depend on the
wasmtime-cachecrate itself, so we'd reexport aswasmtime::CacheConfigto have accessible from the mainwasmtimecrate. Otherwise though definitley agreed it'd be best to support progammatic configuration instead of exclusively file-based configuration.
benbrandt closed issue #10638:
Feature
wasmtime::Config::cache_configfor loading aCacheConfigfrom a struct instead of a file.Benefit
Right now, in order to use the cache, you have to provide a path to a file with the needed configuration.
However, there are cases where the wasmtime is embedded, rather than the CLI, where the cache is still helpful. It would be more convenient to create the configuration programmatically rather than loaded from a file, to allow the application to determine the cache setup based on its own configuration.
Implementation
Expose
wasmtime_cache::CacheConfigfromwasmtimeAdd setters for
wasmtime_cache::CacheConfigso individual fields can be configured.let mut cache_config = wasmtime_cache::CacheConfig::default(); cache_config.with_directory("/path/to/cache");
- Add
cache_configmethod to set this config on thewasmtime::Configlet mut config = wasmtime::Config::default(); config.cache_config(cache_config);Alternatives
Based on the implementation for the method to load from a file, this seems like a straightforward way to allow for a wasmtime user to create their own cache.
If there are other ideas, we could explore those instead.
Last updated: Dec 06 2025 at 07:03 UTC