@iocium/cachekit - v1.0.1
    Preparing search index...

    @iocium/cachekit - v1.0.1

    @iocium/cachekit

    A flexible caching adapter with pluggable backends for Node.js and serverless environments


    • ✅ Modular backend support: Memory, Redis, Memcached, Cloudflare KV, Cloudflare D1
    • ✅ TTL and automatic expiry logic
    • ✅ Works in Node.js and edge/serverless environments
    • ✅ Fully typed and tested with 100% coverage

    npm install @iocium/cachekit
    

    import { createCacheKit, MemoryBackend } from '@iocium/cachekit';

    const cache = createCacheKit();
    await cache.set('key', 'value', 5000); // TTL in ms
    const result = await cache.get('key');

    import { RedisBackend } from '@iocium/cachekit';
    import { createClient } from 'redis';

    const client = createClient();
    await client.connect();
    const cache = createCacheKit({ backend: new RedisBackend(client) });
    import { MemcachedBackend } from '@iocium/cachekit';
    import Memcached from 'memcached';

    const memcached = new Memcached('localhost:11211');
    const cache = createCacheKit({ backend: new MemcachedBackend(memcached) });
    import { KVBackend } from '@iocium/cachekit';
    const cache = createCacheKit({ backend: new KVBackend(MY_KV_NAMESPACE) });
    import { D1Backend } from '@iocium/cachekit';
    const cache = createCacheKit({ backend: new D1Backend(MY_D1_INSTANCE) });

    D1 requires a cache table:

    CREATE TABLE cache (
      key TEXT PRIMARY KEY,
      value TEXT,
      expiresAt INTEGER
    );
    

    npm run test
    npm run test:coverage

    This project is licensed under the MIT License. See the LICENSE file for details.


    Made with 💙 by Iocium