Registry / storage / warp-contracts-redis

warp-contracts-redis

JSON →
library0.4.2jsnpmunverified

Redis-backed SortKeyCache implementation for Warp Contracts (Arweave smart contracts). Version 0.4.2 is the latest stable release, targeting Node.js >=16.5. This package provides an online caching alternative to local caches, with a managed mode that delegates connection lifecycle to the user, solving issues with repeated open/close calls. It uses Lua scripts for atomic operations and supports prefix-based key isolation. Ships TypeScript types.

npm install warp-contracts-redis
INSTALL
IMPORT
SIG · WARP-CONTRACTS-RED
W
warp-contracts-redis
storagejavascriptv0.4.2
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.

RedisCache
import { RedisCache } from 'warp-contracts-redis'
const RedisCache = require('warp-contracts-redis')
The package is ESM-only; does not support CommonJS require().
RedisOptions
import type { RedisOptions } from 'warp-contracts-redis'
import { RedisOptions } from 'warp-contracts-redis'
RedisOptions is a TypeScript type; use dedicated type import to avoid runtime inclusion.
CacheOptions
import type { CacheOptions } from 'warp-contracts'
import { CacheOptions } from 'warp-contracts-redis'
CacheOptions is re-exported from warp-contracts; import directly from warp-contracts to avoid dependency confusion.

Creates a Redis-backed SortKeyCache, writes and reads a value using the contract TX ID and sort key.

import { RedisCache } from 'warp-contracts-redis'; import type { CacheOptions } from 'warp-contracts'; import type { RedisOptions } from 'warp-contracts-redis'; const cacheOptions: CacheOptions = { inMemory: true, dbLocation: 'myapp:cache', subLevelSeparator: '|' }; const redisOptions: RedisOptions = { url: process.env.REDIS_URL ?? 'redis://localhost:6379', minEntriesPerContract: 10, maxEntriesPerContract: 100 }; const cache = new RedisCache(cacheOptions, redisOptions); (async () => { // Example usage const contractTxId = 'contract123'; const sortKey = '000001'; await cache.put(contractTxId, sortKey, { data: 'hello' }); const value = await cache.get(contractTxId, sortKey); console.log('Cached value:', value); })();
Debug
Known issues
breakingThe package is ESM-only; do not use require().
fix
Use import or dynamic import().
affects: >=0.4.0
gotchaWhen using managed mode (passing a custom Redis client), open() and close() are disabled. User must manage connection lifecycle.
fix
Connect the client before passing it to RedisCache; do not rely on cache.open() or cache.close().
affects: >=0.1.0
gotchaCacheOptions.inMemory must be true for RedisCache to work correctly (dumping on close is not supported).
fix
Set inMemory: true in cacheOptions.
affects: >=0.1.0
deprecatedDirect import of CacheOptions from warp-contracts-redis is deprecated; import from warp-contracts instead.
fix
Import type { CacheOptions } from 'warp-contracts'.
affects: >=0.4.0
Errors
Common errors & fixes
Cannot find module 'warp-contracts-redis'
Package not installed or ESM/CJS mismatch in Node.js version may cause resolution failure.
fix
Run 'npm install warp-contracts-redis ioredis warp-contracts'. Ensure Node >=16.5 and project uses ESM (type: module in package.json).
TypeError: RedisCache is not a constructor
Using require() on an ESM-only package.
fix
Change to import { RedisCache } from 'warp-contracts-redis' and ensure project is ESM.
Error: ERR value is not an integer or out of range
Passing non-integer values for minEntriesPerContract or maxEntriesPerContract.
fix
Ensure both options are positive integers.
Upgrade
Version history
0.4.2latest on npm
Audit
Dependencies
ioredisrequiredPeer dependency for interacting with Redis; required at runtime.
warp-contractsrequiredPeer dependency providing the SortKeyCache interface and core Warp types; required at runtime.
Agent activity
39 hits · last 30 days
node
32
Meta
2
Resources
warp-contracts-redis — npm install warp-contracts-redis · libregistry