unoffical wafrn mirror
wafrn.net
atproto
social-network
activitypub
1import { UserOptions } from '../../models/index.js'
2import { redisCache } from '../redis.js'
3
4async function getUserOptions(userId: string): Promise<Array<{ optionName: string; optionValue: string }>> {
5 const cacheReply = await redisCache.get('userOptions:' + userId)
6 if (cacheReply) {
7 return JSON.parse(cacheReply)
8 } else {
9 const dbReply = await UserOptions.findAll({
10 where: {
11 userId: userId
12 }
13 })
14 redisCache.set('userOptions:' + userId, JSON.stringify(dbReply.map((elem: any) => elem.dataValues)), 'EX', 600)
15 return getUserOptions(userId)
16 }
17}
18
19export { getUserOptions }