Registry / testing / async-cache-queue

async-cache-queue

JSON →
library0.2.8jsnpmunverified

A lightweight asynchronous task queue with built-in caching, timeout, throttle, and background prefetching. Version 0.2.8 is stable as of 2025, with infrequent releases. It differentiates from similar libraries (e.g., p-limit, memoizee) by combining queue, concurrency control, positive/negative caching, TTL-based expiration, background refresh, and optional external storage support in a single small package (~2KB gzipped). Ships TypeScript declarations and supports both CJS and ESM.

npm install async-cache-queue
INSTALL
IMPORT
SIG · ASYNC-CACHE-QUEUE
A
async-cache-queue
testingjavascriptv0.2.8
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.

queueFactory
import { queueFactory } from 'async-cache-queue'
const queueFactory = require('async-cache-queue').queueFactory
Using named import with require is also valid, but destructuring is preferred.
clearCache
import { clearCache } from 'async-cache-queue'
const clearCache = require('async-cache-queue').clearCache
Same pattern as queueFactory; available in both CJS and ESM.
default import
import asyncCacheQueue from 'async-cache-queue'
const asyncCacheQueue = require('async-cache-queue')
Default import is not documented and may not work with CJS correctly. Prefer named imports.

Creates a memoized async function with caching, concurrency limit, timeout, and background refresh.

import { queueFactory, clearCache } from 'async-cache-queue'; const memoize = queueFactory({ cache: 3600000, // 1 hour cache for successful results refresh: 60000, // 1 min background prefetch negativeCache: 1000, // 1 sec cache for errors timeout: 10000, // 10 sec operation timeout maxItems: 1000, // max cache entries concurrency: 10, // parallel tasks }); const fetchUser = memoize(async (userId: string) => { const response = await fetch(`https://api.example.com/users/${userId}`); if (!response.ok) throw new Error(`HTTP ${response.status}`); return response.json(); }); async function main() { const user = await fetchUser('123'); console.log(user); } main(); // Clear all caches process.on('SIGHUP', clearCache);
Debug
Known issues
gotchaThe 'cache' option sets TTL for positive cache only; 'negativeCache' for errors. For external storage, cache TTL must be managed externally.
fix
Use 'storage' option with an external store if you need persistent caching; then manage TTL there.
affects: >=0.1.0
deprecatedNo deprecation notices for this version.
fix
N/A
affects: 0.2.8
breakingNo known breaking changes in current version.
fix
N/A
affects: 0.2.8
Errors
Common errors & fixes
TypeError: queueFactory is not a function
Default import used instead of named import.
fix
Use import { queueFactory } from 'async-cache-queue' instead of import queueFactory from 'async-cache-queue'.
Error: Maximum call stack size exceeded
Recursive task calling itself synchronously without awaiting.
fix
Ensure the task function is async and does not call the memoized function synchronously in the same tick.
Upgrade
Version history
0.2.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
async-cache-queue — npm install async-cache-queue · libregistry