Skip to content

How to update or extend the expiration time of a key in Deno KV? #123

@Akimotorakiyu

Description

@Akimotorakiyu

Description

In Deno KV, when using the set method, we can set an expiration time for a key via the expireIn option. However, I'm not sure how to update or extend the expiration time of an existing key.

For example, I have the following code to set a key with an expiration time:

import { openKv } from "deno/kv";

async function main() {
  const kv = await openKv();
  // Set a key with an expiration time of 60 seconds
  await kv.set(["myKey"], "myValue", { expireIn: 60000 }); 
}

After some time, I want to extend the expiration time of myKey by another 60 seconds. But I didn't find a direct method to achieve this in the API documentation.

Questions

Is there a built - in method to update or extend the expiration time of an existing key in Deno KV?
If there is no built - in method, what is the recommended workaround to achieve this functionality?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions