Skip to content

Commit

Permalink
feat: support KV key expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
jviide committed Feb 4, 2024
1 parent 8b91334 commit d4e90be
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/api/kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type KvEntryMaybe<T> =
type AtomicCheck = { key: KvKey; versionstamp: string | null };

type KvMutation =
| { type: "set"; key: KvKey; value: unknown }
| { type: "set"; key: KvKey; value: unknown; expireIn?: number }
| { type: "delete"; key: KvKey };

type KvCommitResult = { ok: true; versionstamp: string };
Expand Down Expand Up @@ -123,8 +123,13 @@ class AtomicOperation {
return this;
}

set(key: KvKey, value: unknown): this {
this._mutations.push({ type: "set", key, value });
set(key: KvKey, value: unknown, options?: { expireIn?: number }): this {
this._mutations.push({
type: "set",
key,
value,
expireIn: options?.expireIn,
});
return this;
}

Expand Down

0 comments on commit d4e90be

Please sign in to comment.