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

Method set

src-tauri/database/src/cache.rs:74–96  ·  view source on GitHub ↗
(&self, _url: &str, blob: &T, expires: i32)

Source from the content-addressed store, hash-verified

72
73 #[tracing::instrument(level = "debug", skip(self, _url, blob, expires))]
74 pub fn set<T>(&self, _url: &str, blob: &T, expires: i32) -> Result<()>
75 where
76 T: Serialize,
77 {
78 let mut conn = self.pool.get().unwrap();
79
80 let current_time = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)?;
81 let new_expires = current_time + Duration::from_secs(expires.unsigned_abs() as u64);
82
83 let cache_model = CacheModel {
84 id: None,
85 url: _url.to_string(),
86 blob: serde_json::to_vec(blob)?,
87 expires: new_expires.as_secs() as i64,
88 };
89 insert_into(cache)
90 .values(&cache_model)
91 .on_conflict(cache_schema::cache::url)
92 .do_update()
93 .set(&cache_model)
94 .execute(&mut conn)?;
95 Ok(())
96 }
97
98 #[tracing::instrument(level = "debug", skip(self, _url))]
99 pub fn get<T>(&self, _url: &str) -> Result<T>

Callers 15

MusicInfoMobileFunction · 0.80
MusicInfoFunction · 0.80
SongListFunction · 0.80
AccountsFunction · 0.80
get_search_resFunction · 0.80
TopBarFunction · 0.80
ColorPickerFunction · 0.80
SatValueSurfaceFunction · 0.80
HueSliderFunction · 0.80
ProviderIconFunction · 0.80
SongViewFunction · 0.80
SidebarFunction · 0.80

Calls 1

getMethod · 0.80

Tested by

no test coverage detected