73 releases (44 stable)

5.0.5-rc1 Jan 3, 2025
5.0.4 Dec 17, 2024
5.0.2 Nov 25, 2024
4.4.0 Oct 4, 2024
1.0.0-alpha5 Nov 6, 2020

#660 in WebAssembly

Download history 9195/week @ 2024-10-22 13337/week @ 2024-10-29 12266/week @ 2024-11-05 6278/week @ 2024-11-12 8958/week @ 2024-11-19 10006/week @ 2024-11-26 8177/week @ 2024-12-03 7011/week @ 2024-12-10 5754/week @ 2024-12-17 9482/week @ 2024-12-24 15382/week @ 2024-12-31 16193/week @ 2025-01-07 19780/week @ 2025-01-14 22007/week @ 2025-01-21 16473/week @ 2025-01-28 15390/week @ 2025-02-04

76,396 downloads per month
Used in 21 crates (6 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
~190K SLoC