Skip to content

Commit

Permalink
feat: CommonKeyValueDBSaveBatchOptions.expireAt
Browse files Browse the repository at this point in the history
For systems like Redis
  • Loading branch information
kirillgroshkov committed Apr 7, 2024
1 parent 939a185 commit 5eaf601
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/kv/commonKeyValueDB.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { UnixTimestampNumber } from '@naturalcycles/js-lib'
import { ReadableTyped } from '@naturalcycles/nodejs-lib'
import { CommonDBCreateOptions } from '../db.model'

export type KeyValueDBTuple = [key: string, value: Buffer]

export interface CommonKeyValueDBSaveBatchOptions {
/**
* If set (and if it's implemented by the driver) - will set expiry TTL for each key of the batch.
* E.g EXAT in Redis.
*/
expireAt?: UnixTimestampNumber
}

/**
* Common interface for Key-Value database implementations.
*
Expand All @@ -29,7 +38,11 @@ export interface CommonKeyValueDB {

deleteByIds: (table: string, ids: string[]) => Promise<void>

saveBatch: (table: string, entries: KeyValueDBTuple[]) => Promise<void>
saveBatch: (
table: string,
entries: KeyValueDBTuple[],
opt?: CommonKeyValueDBSaveBatchOptions,
) => Promise<void>

streamIds: (table: string, limit?: number) => ReadableTyped<string>
streamValues: (table: string, limit?: number) => ReadableTyped<Buffer>
Expand Down

0 comments on commit 5eaf601

Please sign in to comment.