0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-01 12:16:11 -05:00
This commit is contained in:
Bartek Iwańczuk 2025-01-16 01:41:41 +01:00
parent f7f8274881
commit 9b119bcd31
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750

View file

@ -376,6 +376,7 @@ pub struct WebWorkerOptions {
pub format_js_error_fn: Option<Arc<FormatJsErrorFn>>,
pub worker_type: WebWorkerType,
pub cache_storage_dir: Option<std::path::PathBuf>,
pub use_lsc_cache: bool,
pub stdio: Stdio,
pub strace_ops: Option<Vec<String>>,
pub close_on_idle: bool,
@ -453,10 +454,28 @@ impl WebWorker {
// Permissions: many ops depend on this
let enable_testing_features = options.bootstrap.enable_testing_features;
let create_cache = options.cache_storage_dir.map(|storage_dir| {
let create_cache = if options.use_lsc_cache {
use deno_cache::CacheShard;
let Ok(endpoint) = std::env::var("LSC_ENDPOINT") else {
return None;
};
let Ok(token) = std::env::var("LSC_TOKEN") else {
return None;
};
let shard = Rc::new(CacheShard::new(endpoint, token));
let create_cache_fn = move || {
let x = deno_cache::LscBackend::default();
x.set_shard(shard.clone());
x
};
Some(CreateCache(Arc::new(create_cache_fn)))
} else if let Some(storage_dir) = options.cache_storage_dir {
let create_cache_fn = move || SqliteBackedCache::new(storage_dir.clone());
CreateCache(Arc::new(create_cache_fn))
});
Some(CreateCache(Arc::new(create_cache_fn)))
} else {
None
};
// NOTE(bartlomieju): ordering is important here, keep it in sync with
// `runtime/worker.rs` and `runtime/snapshot.rs`!