Registry / storage / chronik-cache

chronik-cache

JSON →
library1.2.3jsnpmunverified

ChronikCache is a high-performance caching layer for Chronik Indexer, designed to accelerate eCash blockchain queries. Current stable version is 1.2.3, released as a TypeScript-first package with full type definitions. It provides automatic background updates via WebSocket synchronization, LevelDB-based persistent storage, and support for address, token, and script history caching. Key differentiators include configurable cache limits, failover logic with retry, real-time cache status tracking (UNKNOWN, UPDATING, LATEST, REJECT), and automatic script-to-address conversion using ecashaddrjs. It requires chronik-client as a peer dependency.

npm install chronik-cache
INSTALL
IMPORT
SIG · CHRONIK-CACHE
C
chronik-cache
storagejavascriptv1.2.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.

default (ChronikCache)
const ChronikCache = require('chronik-cache');
const { ChronikCache } = require('chronik-cache');
Package exports as default, not named. Named export does not exist.
default (ChronikCache)
import ChronikCache from 'chronik-cache';
import { ChronikCache } from 'chronik-cache';
Default import is correct; named import will fail as package has no named exports.
ChronikClient (from chronik-client)
const { ChronikClient } = require('chronik-client');
const ChronikClient = require('chronik-client');
chronik-client exports ChronikClient as a named export, not default.

Shows CommonJS setup with ChronikClient and ChronikCache, configuration, and basic usage to fetch cached address history and check cache status.

const { ChronikClient } = require('chronik-client'); const ChronikCache = require('chronik-cache'); const chronik = new ChronikClient('https://chronik1.alitayin.com'); const cache = new ChronikCache(chronik, { maxTxLimit: 50000, maxCacheSize: 1024, enableLogging: false, wsTimeout: 86000000, failoverOptions: { retryAttempts: 3, retryDelayMs: 1500 } }); async function demo() { const history = await cache.address('ecash:qq...').history(0, 200); console.log('Address history:', history); const status = cache.getCacheStatus('ecash:qq...'); console.log('Cache status:', status); } demo();
Debug
Known issues
gotchaPackage uses CommonJS; ESM import requires default import syntax.
fix
Use `import ChronikCache from 'chronik-cache'` (no named import).
affects: >=1.0.0
gotchaChronikCache constructor requires chronik-client instance; missing or invalid chronik will cause runtime errors.
fix
Ensure chronik-client is installed and instantiated with a valid URL.
affects: >=1.0.0
gotchaCache status codes are not documented in typings; status 1,2,3 have specific meanings as per README.
fix
Refer to README for status code meanings: 1=preparing, 2=limit exceeded, 3=fallback.
affects: >=1.0.0
gotchaLevelDB storage is used but no directory path is configurable; cache location is implicit.
fix
Cache data is stored in a default LevelDB directory; ensure write permissions in the execution environment.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: ChronikCache is not a constructor
Using named import `{ ChronikCache }` when package exports default.
fix
Use `const ChronikCache = require('chronik-cache')` or `import ChronikCache from 'chronik-cache'`.
Cannot find module 'chronik-cache'
chronik-cache not installed or not found in node_modules.
fix
Run `npm install chronik-cache` in your project directory.
TypeError: chronik.address is not a function
chronik instance passed to ChronikCache is invalid or does not have address() method.
fix
Ensure chronik is a proper ChronikClient instance: `new ChronikClient('https://example.com')`.
Upgrade
Version history
1.2.3latest on npm
Audit
Dependencies
chronik-clientrequiredRequired to interact with the Chronik Indexer API
Agent activity
32 hits · last 30 days
node
30
Resources
chronik-cache — npm install chronik-cache · libregistry