Skip to content

Commit

Permalink
Insert to did cache using excluded column (#1772)
Browse files Browse the repository at this point in the history
insert to did cache using exclude
  • Loading branch information
devinivy authored Oct 25, 2023
1 parent ed33f64 commit ce28725
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/bsky/src/did-cache.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PQueue from 'p-queue'
import { CacheResult, DidCache, DidDocument } from '@atproto/identity'
import { PrimaryDatabase } from './db'
import { excluded } from './db/util'
import { dbLogger } from './logger'

export class DidSqlCache implements DidCache {
Expand All @@ -21,7 +22,10 @@ export class DidSqlCache implements DidCache {
.insertInto('did_cache')
.values({ did, doc, updatedAt: Date.now() })
.onConflict((oc) =>
oc.column('did').doUpdateSet({ doc, updatedAt: Date.now() }),
oc.column('did').doUpdateSet({
doc: excluded(this.db.db, 'doc'),
updatedAt: excluded(this.db.db, 'updatedAt'),
}),
)
.executeTakeFirst()
}
Expand Down
2 changes: 1 addition & 1 deletion packages/pds/src/did-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class DidSqlCache implements DidCache {
.onConflict((oc) =>
oc.column('did').doUpdateSet({
doc: excluded(this.db.db, 'doc'),
updatedAt: Date.now(),
updatedAt: excluded(this.db.db, 'updatedAt'),
}),
)
.executeTakeFirst()
Expand Down

0 comments on commit ce28725

Please sign in to comment.