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);
})();
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.
fixRun '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.
fixChange 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.
fixEnsure both options are positive integers.
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.