Skip to content

Commit

Permalink
Fix issue cache key different address format
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Aug 30, 2024
1 parent 0e123f8 commit f40d682
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/pages/api/accounts-data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { redisCallWrapper } from '@/server/cache'
import { getEvmAddressesFromSubsocial } from '@/services/subsocial/evmAddresses/fetcher'
import { toSubsocialAddress } from '@subsocial/utils'
import { request } from 'graphql-request'
import gql from 'graphql-tag'

Expand Down Expand Up @@ -39,12 +40,20 @@ const GET_ENS_NAMES = gql(`

const MAX_AGE = 15 * 60 // 15 minutes
const getRedisKey = (address: string) => {
return `accounts-data:${address}`
try {
return `accounts-data:${toSubsocialAddress(address)}`
} catch {
return ''
}
}

const INVALIDATED_MAX_AGE = 5 * 60 // 5 minutes
const getInvalidatedAccountsDataRedisKey = (id: string) => {
return `accounts-data-invalidated:${id}`
try {
return `accounts-data-invalidated:${toSubsocialAddress(id)}`
} catch {
return ''
}
}

export default async function handler(
Expand Down

0 comments on commit f40d682

Please sign in to comment.