Improve performance of DbGetHandler.

This commit is contained in:
bhartnett 2024-11-04 15:13:56 +08:00
parent 29002618a6
commit 09a9951a13
No known key found for this signature in database
GPG Key ID: 076F2830DA6BD535

View File

@ -457,14 +457,15 @@ proc adjustRadius(
proc createGetHandler*(db: ContentDB): DbGetHandler =
return (
proc(contentKey: ContentKeyByteList, contentId: ContentId): Opt[seq[byte]] =
var res = Opt.none(seq[byte])
var res: seq[byte]
proc onData(data: openArray[byte]) =
res = Opt.some(@data)
res = @data
discard db.get(contentId, onData)
ensureMove(res)
if db.get(contentId, onData):
Opt.some(res)
else:
Opt.none(seq[byte])
)
proc createStoreHandler*(db: ContentDB, cfg: RadiusConfig): DbStoreHandler =