summaryrefslogtreecommitdiff
path: root/cli/cache/http_cache/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/cache/http_cache/mod.rs')
-rw-r--r--cli/cache/http_cache/mod.rs77
1 files changed, 0 insertions, 77 deletions
diff --git a/cli/cache/http_cache/mod.rs b/cli/cache/http_cache/mod.rs
deleted file mode 100644
index 8d09b0995..000000000
--- a/cli/cache/http_cache/mod.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-
-use deno_core::error::AnyError;
-use deno_core::serde::Deserialize;
-use deno_core::serde::Serialize;
-use deno_core::url::Url;
-use std::path::PathBuf;
-use std::time::SystemTime;
-
-use crate::http_util::HeadersMap;
-
-mod common;
-mod global;
-mod local;
-
-pub use global::url_to_filename;
-pub use global::GlobalHttpCache;
-pub use local::LocalHttpCache;
-pub use local::LocalLspHttpCache;
-
-/// Cached metadata about a url.
-#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
-pub struct CachedUrlMetadata {
- pub headers: HeadersMap,
- pub url: String,
- #[serde(default = "SystemTime::now", rename = "now")]
- pub time: SystemTime,
-}
-
-impl CachedUrlMetadata {
- pub fn is_redirect(&self) -> bool {
- self.headers.contains_key("location")
- }
-}
-
-/// Computed cache key, which can help reduce the work of computing the cache key multiple times.
-pub struct HttpCacheItemKey<'a> {
- // The key is specific to the implementation of HttpCache,
- // so keep these private to the module. For example, the
- // fact that these may be stored in a file is an implementation
- // detail.
- #[cfg(debug_assertions)]
- pub(super) is_local_key: bool,
- pub(super) url: &'a Url,
- /// This will be set all the time for the global cache, but it
- /// won't ever be set for the local cache because that also needs
- /// header information to determine the final path.
- pub(super) file_path: Option<PathBuf>,
-}
-
-pub trait HttpCache: Send + Sync + std::fmt::Debug {
- /// A pre-computed key for looking up items in the cache.
- fn cache_item_key<'a>(
- &self,
- url: &'a Url,
- ) -> Result<HttpCacheItemKey<'a>, AnyError>;
-
- fn contains(&self, url: &Url) -> bool;
- fn set(
- &self,
- url: &Url,
- headers: HeadersMap,
- content: &[u8],
- ) -> Result<(), AnyError>;
- fn read_modified_time(
- &self,
- key: &HttpCacheItemKey,
- ) -> Result<Option<SystemTime>, AnyError>;
- fn read_file_bytes(
- &self,
- key: &HttpCacheItemKey,
- ) -> Result<Option<Vec<u8>>, AnyError>;
- fn read_metadata(
- &self,
- key: &HttpCacheItemKey,
- ) -> Result<Option<CachedUrlMetadata>, AnyError>;
-}