| Crates.io | wasmer-cache |
| lib.rs | wasmer-cache |
| version | 7.0.0-rc.1 |
| created_at | 2020-08-15 01:01:07.832195+00 |
| updated_at | 2026-01-23 15:52:25.744341+00 |
| description | Cache system for Wasmer WebAssembly runtime |
| homepage | https://wasmer.io/ |
| repository | https://github.com/wasmerio/wasmer |
| max_upload_size | |
| id | 276876 |
| size | 76,814 |
wasmer-cache The wasmer-cache crate allows to cache WebAssembly modules (of kind
wasmer::Module) in your system, so that next uses of the module does
imply a compilation time.
The Cache trait represents a generic cache for storing and loading
compiled WebAssembly modules. The FileSystemCache type implements
Cache to store cache on the file system.
use wasmer::{DeserializeError, Module, SerializeError};
use wasmer_cache::{Cache, FileSystemCache, Hash};
fn store_module(module: &Module, bytes: &[u8]) -> Result<(), SerializeError> {
// Create a new file system cache.
let mut fs_cache = FileSystemCache::new("some/directory/goes/here")?;
// Compute a key for a given WebAssembly binary
let hash = Hash::generate(bytes);
// Store a module into the cache given a key
fs_cache.store(hash, module.clone())?;
Ok(())
}