( userId: string, refetch = false )
| 34 | * 获取缓存的用户信息 |
| 35 | */ |
| 36 | export async function getCachedUserInfo( |
| 37 | userId: string, |
| 38 | refetch = false |
| 39 | ): Promise<UserBaseInfo> { |
| 40 | const data = await queryClient.fetchQuery( |
| 41 | [CacheKey.user, userId], |
| 42 | () => fetchUserInfo(userId), |
| 43 | { |
| 44 | staleTime: refetch ? 0 : 2 * 60 * 60 * 1000, // 缓存2小时 |
| 45 | } |
| 46 | ); |
| 47 | |
| 48 | return data; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * 获取缓存的会话信息 |
no test coverage detected