npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

intentkit-cache

v1.0.1

Published

Redis cache adapter for IntentKit via ioredis

Downloads

200

Readme

intentkit-cache

Redis cache adapter for IntentKit. Provides a CacheClient via the IntentKit provider system, backed by ioredis.

Install

npm install intentkit-cache ioredis

Quick Start

import { IntentRegistry, createContext, serve } from 'intentkit';
import { createCacheProvider } from 'intentkit-cache';

const registry = new IntentRegistry();
// ... register your functions

const context = createContext();

await serve({
  registry,
  context,
  providers: [
    createCacheProvider({
      host: '127.0.0.1',
      port: 6379,
    }),
  ],
});

Inside any function handler:

import { defineFunction } from 'intentkit';
import { z } from 'zod';
import type { CacheClient } from 'intentkit-cache';

export const getUser = defineFunction({
  name: 'get_user',
  intent: 'Look up a user, checking the cache first.',
  permissions: ['user:read'],
  requires: ['cache'],
  input: z.object({ id: z.string() }),
  output: z.object({ name: z.string() }),
  execute: async (input, ctx) => {
    const cache = ctx.providers.cache as CacheClient;

    const cached = await cache.get(`user:${input.id}`);
    if (cached) return JSON.parse(cached);

    const user = await ctx.db.get<{ name: string }>('SELECT name FROM users WHERE id = ?', [input.id]);
    if (user) {
      await cache.set(`user:${input.id}`, JSON.stringify(user), { ttl: 300 });
    }
    return user ?? { name: 'unknown' };
  },
});

Configuration

| Option | Type | Default | Description | |---|---|---|---| | name | string | 'cache' | Provider name (key in ctx.providers) | | host | string | '127.0.0.1' | Redis host | | port | number | 6379 | Redis port | | password | string | — | Redis AUTH password | | db | number | 0 | Redis database index | | keyPrefix | string | '' | Prefix prepended to all keys | | tls | boolean | false | Enable TLS connection | | connectTimeout | number | 10000 | Connection timeout (ms) | | url | string | — | Redis URL (overrides host/port/password/db) |

Configuration Examples

Local Redis:

createCacheProvider({ host: '127.0.0.1', port: 6379 })

Redis Cloud:

createCacheProvider({
  host: 'redis-12345.c1.us-east-1-2.ec2.cloud.redislabs.com',
  port: 12345,
  password: process.env.REDIS_PASSWORD,
  tls: true,
})

Upstash:

createCacheProvider({
  url: process.env.UPSTASH_REDIS_URL,
  tls: true,
})

Docker Redis:

createCacheProvider({ host: 'redis', port: 6379 })

Example Functions

The package ships with ready-to-use example functions:

import { cacheGet, cacheSet, cacheDelete, cacheListKeys } from 'intentkit-cache/functions';

| Function | Permission | Description | |---|---|---| | cache_get | cache:read | Retrieve a cached value by key | | cache_set | cache:write | Store a value with optional TTL | | cache_delete | cache:write | Delete one or more keys | | cache_list_keys | cache:read | List keys matching a glob pattern |

CacheClient API

| Method | Signature | Description | |---|---|---| | get | (key: string) => Promise<string \| null> | Get value by key | | set | (key: string, value: string, options?: { ttl?: number }) => Promise<void> | Set value with optional TTL (seconds) | | del | (...keys: string[]) => Promise<number> | Delete keys, returns count removed | | exists | (...keys: string[]) => Promise<number> | Count how many keys exist | | expire | (key: string, seconds: number) => Promise<boolean> | Set TTL on existing key | | keys | (pattern: string) => Promise<string[]> | Find keys by glob pattern | | flush | () => Promise<void> | Flush the current database | | ping | () => Promise<boolean> | Health check | | disconnect | () => Promise<void> | Close the connection |

Architecture

Agent (Claude / OpenClaw / custom)
    |
    | calls MCP tool
    v
IntentKit (serve)
    |
    | ctx.providers.cache
    v
intentkit-cache (CacheClient)
    |
    | ioredis
    v
Redis Server

License

MIT