Registry / storage / steplix-cache

steplix-cache

JSON →
library0.0.5jsnpmunverified

A Node.js cache helper supporting memory and Redis backends, with an Express middleware inspired by apicache. Version 0.0.5 provides simple async/await caching with optional TTL and environment-based configuration. The library is lightweight but requires external peer dependencies: 'redis' for Redis backend or 'memory-cache' for memory backend. Currently in early development with sporadic releases.

npm install steplix-cache
INSTALL
IMPORT
SIG · STEPLIX-CACHE
S
steplix-cache
storagejavascriptv0.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cache
✓ const cache = require('steplix-cache');
✗ import cache from 'steplix-cache';
This package does not ship ESM and provides no default export for ESM import. Use require or wrap with createRequire.
apicache
✓ const { apicache } = require('steplix-cache');
✗ const apicache = require('steplix-cache').apicache;
Both patterns work, but destructuring is idiomatic. apicache is a named export.
cache middleware
✓ app.use(apicache('1 hour'));
✗ app.use(apicache);
apicache is a function that returns middleware; calling it without arguments uses default duration but must be called.

Shows basic cache set/get with TTL and Express middleware usage using require and async/await.

const cache = require('steplix-cache'); const { apicache } = require('steplix-cache'); const express = require('express'); async function example() { // Basic set/get with TTL (optional) await cache.put('key', 'value', 100); // 100ms TTL const val = await cache.get('key'); console.log('Cached:', val); // Express middleware const app = express(); app.use(apicache('5 minutes')); app.get('/', (req, res) => res.json({ ok: true })); app.listen(3000); } example().catch(console.error);
Debug
Known issues
gotchaMust install peer dependency explicitly: 'redis' for Redis backend or 'memory-cache' for memory backend. Package does not install them automatically.
fix
Install required backend: npm install steplix-cache redis or npm install steplix-cache memory-cache
affects: >=0.0.1
gotchaCache type defaults to 'memory' if CACHE_TYPE env is not set. To use Redis, ensure CACHE_TYPE=redis and Redis peer dependency installed.
fix
Set environment variable CACHE_TYPE=redis and install redis package.
affects: >=0.0.1
gotchaNo ESM support; package uses CommonJS require(). Import via ESM requires createRequire or dynamic import.
fix
Use require() or create an ESM wrapper with createRequire.
affects: >=0.0.1
gotchaVersion 0.0.5 is very early; API may change without notice. No semver stability.
fix
Pin exact version in package.json and test thoroughly before upgrading.
affects: >=0.0.1
Errors
Common errors & fixes
Error: Cannot find module 'redis'
Missing required peer dependency 'redis' when CACHE_TYPE=redis.
fix
npm install redis
TypeError: cache.put is not a function
Using ESM import syntax (import cache from 'steplix-cache') which doesn't return default export.
fix
Use require('steplix-cache') instead.
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
28
Resources
steplix-cache — npm install steplix-cache · libregistry