pub struct CacheKeyGenerator;Expand description
Cache key generator for document cache
Implementations§
Source§impl CacheKeyGenerator
impl CacheKeyGenerator
Sourcepub fn crate_html_cache_key(crate_name: &str, version: Option<&str>) -> String
pub fn crate_html_cache_key(crate_name: &str, version: Option<&str>) -> String
Build a raw crate HTML cache key with normalization.
This key stores the fetched docs.rs HTML artifact shared across markdown, text, and html responses for the same crate lookup.
Key format: htmlraw:crate:{name} or htmlraw:crate:{name}:{version}
The htmlraw: namespace prefix keeps raw HTML artifacts in a separate
keyspace from rendered documentation keys (crate:...). Without it, a
rendered lookup for version literal "html" (e.g.
crate_cache_key("serde", Some("html")) => crate:serde:html) would
collide with the HTML artifact key for crate_html_cache_key("serde", None), cross-contaminating rendered text and raw HTML.
Sourcepub fn crate_cache_key(crate_name: &str, version: Option<&str>) -> String
pub fn crate_cache_key(crate_name: &str, version: Option<&str>) -> String
Build crate cache key with normalization
§Normalization rules
crate_name: lowercase, trimmed (crate names are case-insensitive on crates.io)version: lowercase, trimmed- Invalid characters in
crate_name(non-alphanumeric, non-underscore, non-hyphen) will result in a hashed key to prevent injection
Sourcepub fn search_cache_key(query: &str, limit: u32, sort: Option<&str>) -> String
pub fn search_cache_key(query: &str, limit: u32, sort: Option<&str>) -> String
Build search cache key with normalization
§Normalization rules
- query: lowercase, trimmed (search is case-insensitive)
- sort: lowercase, trimmed
Sourcepub fn item_cache_key(
crate_name: &str,
item_path: &str,
version: Option<&str>,
) -> String
pub fn item_cache_key( crate_name: &str, item_path: &str, version: Option<&str>, ) -> String
Build item cache key with normalization
§Normalization rules
crate_name: lowercase, trimmed (crate names are case-insensitive on crates.io)item_path: trimmed but case-sensitive (Rust paths are case-sensitive)version: lowercase, trimmed
Sourcepub fn item_html_cache_key(
crate_name: &str,
item_path: &str,
version: Option<&str>,
) -> String
pub fn item_html_cache_key( crate_name: &str, item_path: &str, version: Option<&str>, ) -> String
Build a raw item HTML cache key with normalization.
This key stores the fetched docs.rs search-result HTML artifact shared across markdown, text, and html responses for the same item lookup.
Key format: htmlraw:item:{crate}:{path} (see Self::crate_html_cache_key
for why the htmlraw: namespace is used to avoid collisions).