Registry / database / erxes-inmemory-storage

erxes-inmemory-storage

JSON →
library1.0.20jsnpmunverified

Lightweight in-memory key-value storage with TTL support for Erxes ecosystem. Version 1.0.20 is the current stable release. No recent updates; maintenance mode. Differentiators: simple API with set/get/remove methods and per-key TTL. Alternative is redis.

npm install erxes-inmemory-storage
INSTALL
IMPORT
SIG · ERXES-INMEMORY-STO
E
erxes-inmemory-storage
databasejavascriptv1.0.20
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.

default
✓ import InMemoryStorage from 'erxes-inmemory-storage'
✗ const InMemoryStorage = require('erxes-inmemory-storage').default
Default import is the main class.
InMemoryStorage
✓ import InMemoryStorage from 'erxes-inmemory-storage'
✗ import { InMemoryStorage } from 'erxes-inmemory-storage'
Named import not available; use default import.
MemoryStorage (type)
✓ import type { MemoryStorage } from 'erxes-inmemory-storage'
TypeScript type export; use as type.

Creates in-memory storage instance, sets a key with TTL, reads it, and removes it.

import InMemoryStorage from 'erxes-inmemory-storage'; const storage = new InMemoryStorage(); storage.set('key', 'value', 10000); // 10 second TTL const value = storage.get('key'); console.log(value); // 'value' storage.remove('key'); storage.clear();
Debug
Known issues
gotchaTTL is in milliseconds, not seconds. Using seconds will cause early expiration.
fix
Multiply seconds by 1000 when passing TTL.
affects: >=1.0.0
gotchaStorage is not persistent; data is lost on process restart.
fix
Use a persistent store (e.g., redis) if data must survive restarts.
affects: >=1.0.0
gotchaAll values are stored as strings internally. Objects/numbers are coerced to string.
fix
Explicitly serialize/deserialize non-string values (e.g., JSON.stringify/parse).
affects: >=1.0.0
deprecatedPackage is in maintenance mode. No new features or bug fixes planned.
fix
Consider migrating to a more maintained in-memory storage solution.
affects: >=1.0.20
Errors
Common errors & fixes
TypeError: InMemoryStorage is not a constructor
Using named import instead of default import.
fix
Use: import InMemoryStorage from 'erxes-inmemory-storage'
Value 'undefined' returned for key despite setting it with TTL
TTL in seconds instead of milliseconds causing immediate expiration.
fix
Ensure TTL is in milliseconds (e.g., 10000 for 10 seconds).
Cannot read properties of undefined (reading 'get')
Storage instance not initialized correctly.
fix
Make sure to call 'new InMemoryStorage()' before using methods.
Upgrade
Version history
1.0.20latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Resources
erxes-inmemory-storage — npm install erxes-inmemory-storage · libregistry