chore: backup before migration to new repo

This commit is contained in:
Warren
2026-04-23 16:46:02 +08:00
parent 13dd3b30f3
commit 59809dae1f
40 changed files with 5566 additions and 1783 deletions

View File

@@ -10,6 +10,8 @@ pub const KEY_PREFIX_VIDEO: &str = "video:";
pub const KEY_PREFIX_SEARCH: &str = "search:";
pub const KEY_PREFIX_SEARCH_HYBRID: &str = "search:hybrid:";
pub const KEY_PREFIX_SEARCH_N8N: &str = "search:n8n:";
pub const KEY_PREFIX_SEARCH_BM25: &str = "search:bm25:";
pub const KEY_PREFIX_SEARCH_N8N_BM25: &str = "search:n8n:bm25:";
pub const KEY_HEALTH: &str = "health:basic";
pub fn videos_list(page: usize, limit: usize) -> String {
@@ -32,6 +34,14 @@ pub fn n8n_search(query_hash: &str) -> String {
format!("{}{}", KEY_PREFIX_SEARCH_N8N, query_hash)
}
pub fn bm25_search(query_hash: &str) -> String {
format!("{}{}", KEY_PREFIX_SEARCH_BM25, query_hash)
}
pub fn n8n_bm25_search(query_hash: &str) -> String {
format!("{}{}", KEY_PREFIX_SEARCH_N8N_BM25, query_hash)
}
pub fn health() -> String {
KEY_HEALTH.to_string()
}
@@ -48,6 +58,17 @@ pub fn search_prefix() -> String {
format!("^{}", KEY_PREFIX_SEARCH)
}
pub const KEY_PREFIX_VISUAL_SEARCH: &str = "search:visual:";
pub const CATEGORY_VISUAL_SEARCH: &str = "visual_search";
pub fn visual_search(uuid: &str, criteria_hash: &str) -> String {
format!("{}{}:{}", KEY_PREFIX_VISUAL_SEARCH, uuid, criteria_hash)
}
pub fn visual_search_prefix() -> String {
format!("^{}", KEY_PREFIX_VISUAL_SEARCH)
}
#[cfg(test)]
mod tests {
use super::*;
@@ -78,8 +99,28 @@ mod tests {
assert_eq!(n8n_search("hash123"), "search:n8n:hash123");
}
#[test]
fn test_bm25_search() {
assert_eq!(bm25_search("hash123"), "search:bm25:hash123");
}
#[test]
fn test_n8n_bm25_search() {
assert_eq!(n8n_bm25_search("hash123"), "search:n8n:bm25:hash123");
}
#[test]
fn test_health() {
assert_eq!(health(), "health:basic");
}
#[test]
fn test_visual_search() {
assert_eq!(visual_search("abc123", "hash"), "search:visual:abc123:hash");
}
#[test]
fn test_visual_search_prefix() {
assert_eq!(visual_search_prefix(), "^search:visual:");
}
}

View File

@@ -136,6 +136,10 @@ impl MongoCache {
self.settings.ttl_video_meta
}
pub fn ttl_visual_search(&self) -> u64 {
self.settings.ttl_search // Reuse search TTL
}
pub async fn get<T: DeserializeOwned>(&self, key: &str) -> Result<Option<T>> {
if !self.is_enabled() {
return Ok(None);