71 releases (43 stable)

new 5.0.3 Dec 7, 2024
5.0.2 Nov 25, 2024
5.0.0 Oct 29, 2024
4.4.0 Oct 4, 2024
1.0.0-alpha5 Nov 6, 2020

#929 in WebAssembly

Download history 36084/week @ 2024-08-17 16292/week @ 2024-08-24 11987/week @ 2024-08-31 12341/week @ 2024-09-07 7021/week @ 2024-09-14 7548/week @ 2024-09-21 9936/week @ 2024-09-28 12946/week @ 2024-10-05 11580/week @ 2024-10-12 10298/week @ 2024-10-19 12026/week @ 2024-10-26 10571/week @ 2024-11-02 9196/week @ 2024-11-09 8104/week @ 2024-11-16 7036/week @ 2024-11-23 9900/week @ 2024-11-30

35,219 downloads per month
Used in 17 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–14MB
~193K SLoC