Skip to content

Commit

Permalink
fix: did cache key not being set correctly (#1394)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <timo@animo.id>
  • Loading branch information
TimoGlastra committed Mar 21, 2023
1 parent dbfebb4 commit 1125e81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions packages/indy-sdk/src/ledger/IndySdkPoolService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export class IndySdkPoolService {
}

const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache
const cachedNymResponse = await cache.get<CachedDidResponse>(agentContext, `IndySdkPoolService:${did}`)
const cacheKey = `IndySdkPoolService:${did}`

const cachedNymResponse = await cache.get<CachedDidResponse>(agentContext, cacheKey)
const pool = this.pools.find((pool) => pool.didIndyNamespace === cachedNymResponse?.indyNamespace)

// If we have the nym response with associated pool in the cache, we'll use that
Expand Down Expand Up @@ -145,7 +147,7 @@ export class IndySdkPoolService {
value = productionOrNonProduction[0].value
}

await cache.set(agentContext, `IndySdkPoolService:${did}`, {
await cache.set(agentContext, cacheKey, {
nymResponse: value.did,
indyNamespace: value.pool.didIndyNamespace,
} satisfies CachedDidResponse)
Expand Down
7 changes: 4 additions & 3 deletions packages/indy-vdr/src/pool/IndyVdrPoolService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ export class IndyVdrPoolService {
)
}

const didCache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache
const cache = agentContext.dependencyManager.resolve(CacheModuleConfig).cache
const cacheKey = `IndyVdrPoolService:${did}`

const cachedNymResponse = await didCache.get<CachedDidResponse>(agentContext, `IndyVdrPoolService:${did}`)
const cachedNymResponse = await cache.get<CachedDidResponse>(agentContext, cacheKey)
const pool = this.pools.find((pool) => pool.indyNamespace === cachedNymResponse?.indyNamespace)

// If we have the nym response with associated pool in the cache, we'll use that
Expand Down Expand Up @@ -122,7 +123,7 @@ export class IndyVdrPoolService {
value = productionOrNonProduction[0].value
}

await didCache.set(agentContext, did, {
await cache.set(agentContext, cacheKey, {
nymResponse: {
did: value.did.nymResponse.did,
verkey: value.did.nymResponse.verkey,
Expand Down

0 comments on commit 1125e81

Please sign in to comment.