Configuration
Configure redis-graph-cache to match your application's needs.
const cache = new RedisGraphCache(schema, {
redis: { /* ... */ },
cache: { /* ... */ },
limits: { /* ... */ },
resilience: { /* ... */ },
monitoring: { /* ... */ },
safety: { /* ... */ },
});All sections are optional; partial configs are deep-merged with the defaults shown below.
Redis Configuration
Extends standard ioredis RedisOptions. Configure connection settings and pooling.
| Option | Type | Default | Description |
|---|---|---|---|
host | string | 'localhost' | Redis host |
port | number | 6379 | Redis port |
db | number | 0 | Redis database number |
password | string | – | Redis auth password |
keyPrefix | string | '' | Prepended to every key. Auto-suffixes : if missing |
poolSize | number | 1 | Number of ioredis clients (round-robined). Use 4–8 in production |
| ...all other ioredis options | – | – | TLS, sentinel, retry strategies, etc. |
Key namespacing
When keyPrefix is set, clearAllCache switches from FLUSHDB to non-blocking scoped SCAN + UNLINK. Strongly recommended when sharing Redis with other apps/envs.
Cache Configuration
Configure caching behavior, TTL defaults, and serialization options.
| Option | Type | Default | Description |
|---|---|---|---|
defaultTTL | number (s) | 3600 | Fallback TTL when schema doesn't specify one |
enableCompression | boolean | false | Auto-zlib entity payloads larger than threshold |
compressionThreshold | number (bytes) | 1024 | Min payload size to compress |
enableL1Cache | boolean | false | Reserved (in-process L1 cache, not yet implemented) |
serializer | Serializer | TAGGED_SERIALIZER | Lossless tagged JSON. Pass JSON_SERIALIZER for raw JSON |
l1CacheSize | number | 1000 | Reserved |
Limits Configuration
Configure operational limits to prevent resource exhaustion.
| Option | Type | Default | Description |
|---|---|---|---|
maxHydrationDepth | number | 5 | Throws HydrationDepthExceededError if exceeded |
maxEntitiesPerRequest | number | 1000 | Cap on entities hydrated per call |
maxMemoryUsagePerOperation | number (bytes) | 100 MB | Throws MemoryLimitError if exceeded |
maxConcurrentOperations | number | 100 | Reserved |
batchSize | number | 100 | Pipeline batch size for bulk ops |
Resilience Configuration
Configure circuit breaker, retry logic, and fallback strategies.
resilience: {
circuitBreaker: { threshold: 5, timeout: 60000, resetTimeout: 30000 },
retry: { maxAttempts: 3, baseDelay: 100, maxDelay: 2000, backoffFactor: 2 },
fallback: { enabled: true, strategy: 'null' }, // 'null' | 'empty' | 'cached' | 'custom'
}| Section | Option | Default | Description |
|---|---|---|---|
circuitBreaker | threshold | 5 | Consecutive failures before tripping OPEN |
timeout | 60000 ms | Max op duration before counted as failure | |
resetTimeout | 30000 ms | OPEN → HALF_OPEN cool-down | |
retry | maxAttempts | 3 | Max retries per op |
baseDelay | 100 ms | Initial backoff | |
maxDelay | 2000 ms | Cap on exponential backoff | |
backoffFactor | 2 | Multiplier per attempt | |
fallback | enabled | true | Whether to apply a fallback when ops fail |
strategy | 'null' | 'null' | 'empty' | 'cached' | 'custom' |
Monitoring Configuration
Configure metrics collection and logging.
| Option | Type | Default | Description |
|---|---|---|---|
enableMetrics | boolean | true | Track hits, misses, latency |
enableDebugMode | boolean | false | Reserved |
enableAuditLog | boolean | false | Reserved |
metricsInterval | number | 60000 | Reserved |
logLevel | 'error' | 'warn' | 'info' | 'debug' | 'info' | Reserved |
Safety Configuration
Configure production safety guards.
| Option | Type | Default | Description |
|---|---|---|---|
productionMode | boolean | NODE_ENV === 'production' | Blocks clearAllCache unless allowProduction: true |
Reserved options
cache.enableL1Cache, cache.l1CacheSize, and redis.connectionPool are accepted for forward compatibility but are not currently used. Use redis.poolSize for connection pooling.