70 releases (42 stable)

new 5.0.2 Nov 25, 2024
5.0.0 Oct 29, 2024
4.4.0 Oct 4, 2024
4.3.5 Jul 16, 2024
1.0.0-alpha5 Nov 6, 2020

#697 in WebAssembly

Download history 21944/week @ 2024-08-05 14627/week @ 2024-08-12 39608/week @ 2024-08-19 12308/week @ 2024-08-26 13142/week @ 2024-09-02 10987/week @ 2024-09-09 6783/week @ 2024-09-16 7137/week @ 2024-09-23 10223/week @ 2024-09-30 15122/week @ 2024-10-07 9874/week @ 2024-10-14 10322/week @ 2024-10-21 11959/week @ 2024-10-28 9956/week @ 2024-11-04 9634/week @ 2024-11-11 7461/week @ 2024-11-18

39,482 downloads per month
Used in 22 crates (5 directly)

MIT license

740KB
15K SLoC

wasmer-cache Build Status Join Wasmer Slack MIT License

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.

Usage

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(())
}

Dependencies

~4–15MB
~194K SLoC