Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/keyv/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ export class Keyv<GenericValue = any> extends Hookified {
*/
// biome-ignore lint/correctness/noUnusedVariables: type format
async setMany<Value = GenericValue>(
entries: KeyvEntry[],
entries: KeyvEntry<Value>[],
): Promise<boolean[]> {
let results: boolean[] = [];

Expand Down
11 changes: 4 additions & 7 deletions core/keyv/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ export enum KeyvHooks {
AFTER_DELETE = "after:delete",
}

export type KeyvEntry = {
// biome-ignore lint/suspicious/noExplicitAny: type format
export type KeyvEntry<Value = any> = {
/**
* Key to set.
*/
key: string;
/**
* Value to set.
*/
// biome-ignore lint/suspicious/noExplicitAny: type format
value: any;
value: Value;
/**
* Time to live in milliseconds.
*/
Expand All @@ -101,10 +101,7 @@ export type KeyvStorageAdapter = {
get<Value>(key: string): Promise<StoredData<Value> | undefined>;
// biome-ignore lint/suspicious/noExplicitAny: type format
set(key: string, value: any, ttl?: number): any;
setMany?(
// biome-ignore lint/suspicious/noExplicitAny: type format
values: Array<{ key: string; value: any; ttl?: number }>,
): Promise<boolean[] | undefined>;
setMany?(values: KeyvEntry[]): Promise<boolean[] | undefined>;
delete(key: string): Promise<boolean>;
clear(): Promise<void>;
has?(key: string): Promise<boolean>;
Expand Down
11 changes: 7 additions & 4 deletions storage/dynamo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ import {
type ScanCommandOutput,
} from "@aws-sdk/lib-dynamodb";
import { Hookified } from "hookified";
import { Keyv, type KeyvStorageAdapter, type StoredData } from "keyv";
import {
Keyv,
type KeyvEntry,
type KeyvStorageAdapter,
type StoredData,
} from "keyv";

export class KeyvDynamo extends Hookified implements KeyvStorageAdapter {
private _sixHoursInMilliseconds = 6 * 60 * 60 * 1000;
Expand Down Expand Up @@ -203,9 +208,7 @@ export class KeyvDynamo extends Hookified implements KeyvStorageAdapter {
* Stores multiple values in DynamoDB.
* @param entries - An array of objects containing key, value, and optional ttl
*/
public async setMany(
entries: Array<{ key: string; value: unknown; ttl?: number }>,
): Promise<boolean[] | undefined> {
public async setMany(entries: KeyvEntry[]): Promise<boolean[] | undefined> {
try {
await this._tableReady;

Expand Down
6 changes: 2 additions & 4 deletions storage/etcd/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Etcd3, type Lease } from "etcd3";
import { Hookified } from "hookified";
import { Keyv, type StoredData } from "keyv";
import { Keyv, type KeyvEntry, type StoredData } from "keyv";
import type {
ClearOutput,
DeleteOutput,
Expand Down Expand Up @@ -326,9 +326,7 @@ export class KeyvEtcd<Value = any> extends Hookified {
* Stores multiple values in the etcd server.
* @param entries - An array of objects containing key and value
*/
public async setMany(
entries: Array<{ key: string; value: Value }>,
): Promise<boolean[] | undefined> {
public async setMany(entries: KeyvEntry[]): Promise<boolean[] | undefined> {
const promises = entries.map(async ({ key, value }) =>
this.set(key, value),
);
Expand Down
7 changes: 2 additions & 5 deletions storage/memcache/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Hookified } from "hookified";
import type { KeyvStorageAdapter, StoredData } from "keyv";
import type { KeyvEntry, KeyvStorageAdapter, StoredData } from "keyv";
import { Keyv } from "keyv";
import { Memcache, type MemcacheOptions } from "memcache";

Expand Down Expand Up @@ -119,10 +119,7 @@ export class KeyvMemcache extends Hookified implements KeyvStorageAdapter {
* Stores multiple values in the memcache server.
* @param entries - An array of objects containing key, value, and optional ttl
*/
async setMany(
// biome-ignore lint/suspicious/noExplicitAny: type format
entries: Array<{ key: string; value: any; ttl?: number }>,
): Promise<boolean[] | undefined> {
async setMany(entries: KeyvEntry[]): Promise<boolean[] | undefined> {
const promises = entries.map(async ({ key, value, ttl }) =>
this.set(key, value, ttl),
);
Expand Down
11 changes: 6 additions & 5 deletions storage/mongo/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Buffer } from "node:buffer";
import { Hookified } from "hookified";
import Keyv, { type KeyvStorageAdapter, type StoredData } from "keyv";
import Keyv, {
type KeyvEntry,
type KeyvStorageAdapter,
type StoredData,
} from "keyv";
import {
type Document,
GridFSBucket,
Expand Down Expand Up @@ -369,10 +373,7 @@ export class KeyvMongo extends Hookified implements KeyvStorageAdapter {
* In GridFS mode, each entry is set individually in parallel.
* @param entries - Array of entries to set. Each entry has a `key`, `value`, and optional `ttl` in milliseconds.
*/
public async setMany(
// biome-ignore lint/suspicious/noExplicitAny: type format
entries: Array<{ key: string; value: any; ttl?: number }>,
): Promise<boolean[] | undefined> {
public async setMany(entries: KeyvEntry[]): Promise<boolean[] | undefined> {
if (this._useGridFS) {
const settled = await Promise.allSettled(
entries.map(async ({ key, value, ttl }) => this.set(key, value, ttl)),
Expand Down
11 changes: 6 additions & 5 deletions storage/valkey/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import calculateSlot from "cluster-key-slot";
import { Hookified } from "hookified";
import Redis, { type Cluster } from "iovalkey";
import Keyv, { type KeyvStorageAdapter, type StoredData } from "keyv";
import Keyv, {
type KeyvEntry,
type KeyvStorageAdapter,
type StoredData,
} from "keyv";
import type { KeyvUriOptions, KeyvValkeyOptions } from "./types.js";

/**
Expand Down Expand Up @@ -261,10 +265,7 @@ class KeyvValkey extends Hookified implements KeyvStorageAdapter {
* containing `key`, `value`, and an optional `ttl` in milliseconds for each entry.
* @returns {Promise<void>}
*/
public async setMany(
// biome-ignore lint/suspicious/noExplicitAny: type format
entries: Array<{ key: string; value: any; ttl?: number }>,
): Promise<boolean[] | undefined> {
public async setMany(entries: KeyvEntry[]): Promise<boolean[] | undefined> {
if (entries.length === 0) {
return entries.map(() => true);
}
Expand Down
Loading