1个稳定版本
1.0.2 | 2021年2月6日 |
---|
1344 在 WebAssembly 中
210KB
3.5K SLoC
wasmer-cache

wasmer-cache
crate 允许在您的系统中缓存WebAssembly模块(类型为 wasmer::Module
),这样下次使用模块时不需要编译时间。
用法
Cache
特征表示一个通用的缓存,用于存储和加载编译后的WebAssembly模块。 FileSystemCache
类型实现了 Cache
以在文件系统上存储缓存。
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(())
}
依赖关系
~10MB
~205K SLoC