ProvenPin Install

Keyv in-memory store with TTL expiry: working versions (tested 2026-10-15)

Use Keyv's default Map store to set, get, and expire values with TTL offline.

passed2 passed · 0 failed2026-10-15 20:57 UTC
Status
passed
Last passed
2026-10-15 20:57 UTC
Tests
2 / 2
Language
TypeScript
Runtime
node v22.23.3
pinned versions3
keyv@6.1.0@types/node@26.6.5tsx@4.23.15
run it
npm install --no-audit --no-fund --ignore-scripts=false
npm test
test environment
node v22.23.3
linux 6.17.0-1022-azure
x64
runner: github-actions 38805962781

The code

Exactly the files that passed. Your agent can pull them with get_recipe("keyv-memory-ttl") (install), or see them on GitHub.

package.json
{
  "name": "keyv-memory-ttl",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {
    "keyv": "6.1.0"
  },
  "devDependencies": {
    "@types/node": "26.6.5",
    "tsx": "4.23.15"
  }
}
src/cache.ts
import Keyv from "keyv";

export function createMemoryCache(namespace = "demo") {
  return new Keyv({ namespace });
}

export async function setWithTtl<T>(cache: Keyv, key: string, value: T, ttlMs: number) {
  await cache.set(key, value, ttlMs);
}

export async function getValue<T>(cache: Keyv, key: string) {
  return (await cache.get(key)) as T | undefined;
}
test/cache.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { setTimeout as sleep } from "node:timers/promises";
import { createMemoryCache, getValue, setWithTtl } from "../src/cache.ts";

test("stores and retrieves values", async () => {
  const cache = createMemoryCache("t1");
  await setWithTtl(cache, "user", { id: 1 }, 5000);
  assert.deepEqual(await getValue(cache, "user"), { id: 1 });
  await cache.disconnect();
});

test("ttl expires entries", async () => {
  const cache = createMemoryCache("t2");
  await setWithTtl(cache, "temp", "x", 80);
  assert.equal(await getValue(cache, "temp"), "x");
  await sleep(150);
  assert.equal(await getValue(cache, "temp"), undefined);
  await cache.disconnect();
});

Connect to ProvenPin

Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.

terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp

Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.