Registry / database / next-cache

next-cache

JSON →
library1.3.3jsnpmunverified

NextCache is a server-side rendering cache service designed for clustering and distributed applications. It provides a WebSocket-based client-server architecture for caching SSR data, with TTL support and async value resolution. Version 1.3.3 requires Node.js 10.15.3 and npm 6.4.1. Compared to other caching solutions, NextCache is specialized for SSR caching and uses WebSockets for real-time communication.

npm install next-cache
INSTALL
IMPORT
SIG · NEXT-CACHE
N
next-cache
databasejavascriptv1.3.3
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.

Server
const { Server } = require('next-cache');
import { Server } from 'next-cache';
This package is CommonJS-only; does not support ESM imports.
Client
const { Client } = require('next-cache');
import { Client } from 'next-cache';
Same as Server, CJS only.
default export
const NextCache = require('next-cache'); // then use NextCache.Server or NextCache.Client
import NextCache from 'next-cache';
No default export; use namespace import.

Demonstrates starting a NextCache server and using the client to fetch cached data with a TTL of 1 hour.

const { Server, Client } = require('next-cache'); // Start server const server = new Server({ port: 666 }); server.start(); // Client usage const client = new Client('ws://localhost:666'); async function main() { await client.connect(); const data = await client.get('myKey', async () => { // Simulate async data fetch return await new Promise(resolve => { setTimeout(() => { resolve({ value: { hello: 'world' }, ttl: 3600 }); }, 1000); }); }); console.log(data); // { hello: 'world' } } main().catch(console.error);
Debug
Known issues
breakingRequires Node.js 10.15.3 or higher. Older Node versions are not supported.
fix
Upgrade Node.js to version 10.15.3+.
affects: <10.15.3
deprecatedPackage has not been updated since 2019 and may have unpatched vulnerabilities in dependencies.
fix
Consider migrating to an actively maintained caching solution like ioredis or lru-cache.
affects: all
gotchaWebSocket client must call connect() before any cache operations. Calling get() without connect will throw an error.
fix
Always await client.connect() before using client.get().
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: WebSocket is not defined
The 'ws' package may not be installed or the environment lacks WebSocket support (e.g., in older Node.js).
fix
Install 'ws' via npm install ws and ensure Node.js >= 10.15.3.
Error: connect ECONNREFUSED
The NextCache server is not running or the client URL is incorrect.
fix
Start the server first and verify the WebSocket URL (e.g., ws://localhost:666).
TypeError: client.get is not a function
The client instance was not properly initialized or connect() was not called.
fix
Ensure you create a new Client and await connect() after instantiation.
Upgrade
Version history
1.3.3latest on npm
Audit
Dependencies
wsrequiredWebSockets library for client-server communication
Agent activity
2 hits · last 30 days
node
2
Resources
next-cache — npm install next-cache · libregistry