more debugging logs
This commit is contained in:
@ -206,6 +206,8 @@ export const userDigestEligible = async (uid: string): Promise<boolean> => {
|
||||
const featuresCacheKey = (userId: string) => `cache:features:${userId}`
|
||||
|
||||
export const getFeaturesCache = async (userId: string) => {
|
||||
logger.debug('getFeaturesCache', { userId })
|
||||
|
||||
const cachedFeatures = await redisDataSource.redisClient?.get(
|
||||
featuresCacheKey(userId)
|
||||
)
|
||||
@ -218,6 +220,9 @@ export const getFeaturesCache = async (userId: string) => {
|
||||
|
||||
export const setFeaturesCache = async (userId: string, features: Feature[]) => {
|
||||
const value = JSON.stringify(features)
|
||||
|
||||
logger.debug('setFeaturesCache', { userId, value })
|
||||
|
||||
return redisDataSource.redisClient?.set(
|
||||
featuresCacheKey(userId),
|
||||
value,
|
||||
|
||||
@ -1724,6 +1724,11 @@ const totalCountCacheKey = (userId: string, args: SearchArgs) => {
|
||||
}
|
||||
|
||||
export const getCachedTotalCount = async (userId: string, args: SearchArgs) => {
|
||||
logger.debug('Getting cached total count:', {
|
||||
userId,
|
||||
args,
|
||||
})
|
||||
|
||||
const cacheKey = totalCountCacheKey(userId, args)
|
||||
const cachedCount = await redisDataSource.redisClient?.get(cacheKey)
|
||||
if (!cachedCount) {
|
||||
@ -1739,6 +1744,12 @@ export const setCachedTotalCount = async (
|
||||
count: number
|
||||
) => {
|
||||
const cacheKey = totalCountCacheKey(userId, args)
|
||||
|
||||
logger.debug('Setting cached total count:', {
|
||||
cacheKey,
|
||||
count,
|
||||
})
|
||||
|
||||
await redisDataSource.redisClient?.set(cacheKey, count, 'EX', 600)
|
||||
}
|
||||
|
||||
@ -1749,6 +1760,10 @@ export const deleteCachedTotalCount = async (userId: string) => {
|
||||
return
|
||||
}
|
||||
|
||||
logger.debug('Deleting keys:', keys)
|
||||
logger.debug('Deleting keys:', {
|
||||
keys,
|
||||
userId,
|
||||
})
|
||||
|
||||
await redisDataSource.redisClient?.del(keys)
|
||||
}
|
||||
|
||||
@ -161,6 +161,8 @@ export const findUserAndPersonalization = async (id: string) => {
|
||||
const userCacheKey = (id: string) => `cache:user:${id}`
|
||||
|
||||
export const getCachedUser = async (id: string) => {
|
||||
logger.debug(`Getting user from cache: ${id}`)
|
||||
|
||||
const user = await redisDataSource.redisClient?.get(userCacheKey(id))
|
||||
if (!user) {
|
||||
return undefined
|
||||
@ -170,6 +172,8 @@ export const getCachedUser = async (id: string) => {
|
||||
}
|
||||
|
||||
export const cacheUser = async (user: User) => {
|
||||
logger.debug(`Caching user: ${user.id}`)
|
||||
|
||||
await redisDataSource.redisClient?.set(
|
||||
userCacheKey(user.id),
|
||||
JSON.stringify(user),
|
||||
|
||||
@ -4,6 +4,7 @@ import { Subscription, SubscriptionStatus } from '../entity/subscription'
|
||||
import { Shortcut, UserPersonalization } from '../entity/user_personalization'
|
||||
import { redisDataSource } from '../redis_data_source'
|
||||
import { authTrx } from '../repository'
|
||||
import { logger } from '../utils/logger'
|
||||
import { findLabelsByUserId } from './labels'
|
||||
|
||||
export const findUserPersonalization = async (userId: string) => {
|
||||
@ -177,6 +178,8 @@ const userDefaultShortcuts = async (userId: string): Promise<Shortcut[]> => {
|
||||
const shortcutsCacheKey = (userId: string) => `cache:shortcuts:${userId}`
|
||||
|
||||
export const getShortcutsCache = async (userId: string) => {
|
||||
logger.debug(`Getting shortcuts from cache: ${userId}`)
|
||||
|
||||
const cachedShortcuts = await redisDataSource.redisClient?.get(
|
||||
shortcutsCacheKey(userId)
|
||||
)
|
||||
@ -187,6 +190,8 @@ export const getShortcutsCache = async (userId: string) => {
|
||||
}
|
||||
|
||||
export const cacheShortcuts = async (userId: string, shortcuts: Shortcut[]) => {
|
||||
logger.debug(`Caching shortcuts: ${userId}`)
|
||||
|
||||
await redisDataSource.redisClient?.set(
|
||||
shortcutsCacheKey(userId),
|
||||
JSON.stringify(shortcuts),
|
||||
|
||||
Reference in New Issue
Block a user