Registry / database / redis-collection

redis-collection

JSON →
library0.0.1jsnpmunverified

An async utility data structure library using Redis as the backing store, providing map-like collections with automatic persistence. This is an early-stage package (v0.0.1) with TypeScript support. It differentiates itself from similar libraries by focusing on simple async data structures (like maps) that synchronize state with Redis, suitable for distributed applications requiring shared state across processes or servers without a full ORM. The library aims to be lightweight with minimal dependencies, appealing to developers needing quick Redis-backed caches or stores. However, as a pre-1.0 release, APIs are unstable and documentation is sparse.

npm install redis-collection
INSTALL
IMPORT
SIG · REDIS-COLLECTION
R
redis-collection
databasejavascriptv0.0.1
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.

RedisCollection
import { RedisCollection } from 'redis-collection'
const RedisCollection = require('redis-collection');
The library is ESM-only (no CommonJS export). Use dynamic import() or configure your project for ESM.
Map
import { Map } from 'redis-collection'
import Map from 'redis-collection';
Map is a named export, not default. CommonJS require will fail because the package has no default export.
createCollection
import { createCollection } from 'redis-collection'
import { create_collection } from 'redis-collection'
Function name is camelCase, not snake_case. TypeScript types are included, but may be incomplete.

Sets up a Redis client, creates a Map collection, performs put/get/exists/delete operations, and cleans up resources.

import { createClient } from 'redis'; import { Map } from 'redis-collection'; async function main() { const redisClient = createClient({ url: process.env.REDIS_URL ?? 'redis://localhost:6379' }); await redisClient.connect(); const myMap = new Map<string, string>({ client: redisClient, prefix: 'myapp:' }); await myMap.set('foo', 'bar'); const value = await myMap.get('foo'); console.log(value); // 'bar' const exists = await myMap.has('foo'); console.log(exists); // true await myMap.delete('foo'); await myMap.destroy(); await redisClient.quit(); } main().catch(console.error);
Debug
Known issues
breakingAPI is unstable and may change without notice before v1.0.0.
fix
Pin to exact version and test upgrades thoroughly.
affects: <1.0.0
gotchaAll operations are async; forgetting to await will result in undefined behavior or silent failures.
fix
Always use await or handle promises properly.
affects: >=0.0.1
gotchaDoes not handle Redis connection errors internally; uncaught exceptions may crash the process.
fix
Add try-catch around async operations or attach error handler to Redis client.
affects: >=0.0.1
gotchaMap keys and values must be serializable to strings via JSON.stringify; complex objects may lose type information.
fix
Use only primitive types or ensure your objects are JSON-safe.
affects: >=0.0.1
deprecatedNo known deprecations yet, but be aware the package is pre-1.0.
fix
Monitor the GitHub repository for breaking changes.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: redis_collection_1.default is not a constructor
Attempting to default-import from an ESM-only package that only exports named exports.
fix
Use named import: import { Map } from 'redis-collection'
Cannot find module 'redis-collection'
Package not installed or not in node_modules.
fix
Run npm install redis-collection
TypeError: Cannot read properties of undefined (reading 'get')
Forgot to await the async Map constructor or called get on a non-existent Map instance.
fix
Ensure await is used: const map = await new Map({...}).init(); or similar if constructor is async.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies
redisrequiredRequired for Redis client operations. The library abstracts over the official Redis Node.js client.
Agent activity
25 hits · last 30 days
node
20
Meta
1
Amazon
1
OpenAI (training)
1
Resources
redis-collection — npm install redis-collection · libregistry