MCPcopy Create free account
hub / github.com/Moosync/Moosync / get

Method get

src-tauri/database/src/cache.rs:99–116  ·  view source on GitHub ↗
(&self, _url: &str)

Source from the content-addressed store, hash-verified

97
98 #[tracing::instrument(level = "debug", skip(self, _url))]
99 pub fn get<T>(&self, _url: &str) -> Result<T>
100 where
101 T: for<'a> Deserialize<'a>,
102 {
103 let mut conn = self.pool.get().unwrap();
104
105 let data: CacheModel = cache.filter(url.eq(_url)).first::<CacheModel>(&mut conn)?;
106 let current_time = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)?;
107
108 let expires = Duration::from_secs(data.expires as u64);
109 if current_time > expires {
110 debug!("Cache expired for {}", _url);
111 return Err("Cache expired".into());
112 }
113
114 let parsed: T = serde_json::from_slice(&data.blob)?;
115 Ok(parsed)
116 }
117}

Callers 15

scan_musicMethod · 0.80
mainFunction · 0.80
MainAppFunction · 0.80
AppFunction · 0.80
MusicInfoMobileFunction · 0.80
MusicInfoFunction · 0.80
SongListFunction · 0.80
TopBarFunction · 0.80
ColorPickerFunction · 0.80
HueSliderFunction · 0.80
SongViewFunction · 0.80

Calls 1

eqMethod · 0.45

Tested by 2

test_album_operationsFunction · 0.64
test_artist_operationsFunction · 0.64