futu_cache/
user_profile.rs1use dashmap::DashMap;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
4pub struct UserProfile {
5 pub user_id: u64,
6 pub nick_name: String,
7 pub avatar_url: String,
8}
9
10#[derive(Debug, Default)]
11pub struct UserProfileCache {
12 profiles: DashMap<u64, UserProfile>,
13}
14
15impl UserProfileCache {
16 pub fn new() -> Self {
17 Self::default()
18 }
19
20 pub fn set(&self, profile: UserProfile) {
21 self.profiles.insert(profile.user_id, profile);
22 }
23
24 pub fn get(&self, user_id: u64) -> Option<UserProfile> {
25 self.profiles.get(&user_id).map(|entry| entry.clone())
26 }
27}