Skip to content

Commit

Permalink
Merge pull request #703 from dappforce/fix/cache
Browse files Browse the repository at this point in the history
Fix issue cache key different address format
  • Loading branch information
teodorus-nathaniel authored Aug 30, 2024
2 parents 9f1c74a + f40d682 commit 7411556
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 7411556

Please sign in to comment.