A photo manager for VRChat.
1use std::{ collections::HashMap, sync::Mutex }; 2 3pub struct Cache{ 4 store: Mutex<HashMap<String, String>>, 5} 6 7impl Cache{ 8 pub fn new() -> Self{ 9 Cache { 10 store: Mutex::new(HashMap::new()) 11 } 12 } 13 14 pub fn insert( &self, key: String, value: String ){ 15 self.store.lock().unwrap().insert(key, value); 16 } 17 18 pub fn get( &self, key: String ) -> Option<String>{ 19 let store = self.store.lock().unwrap(); 20 let val = store.get(&key); 21 22 if val.is_none(){ 23 None 24 } else{ 25 Some(val.unwrap().clone()) 26 } 27 } 28}