@telefunc/redis
Environment: server.
Beta — Telefunc Stream is in beta: breaking changes may occur in any version update.
Redis-backed broadcast fan-out across server instances — a publish() on any instance reaches every subscribe() on every other instance.
You only need this if you scale horizontally — see Stream at Scale.
Install
npm install @telefunc/redis ioredispnpm add @telefunc/redis ioredisbun add @telefunc/redis ioredisyarn add @telefunc/redis ioredis// Environment: server
import IORedis from 'ioredis'
import { installRedis } from '@telefunc/redis'
const redis = new IORedis('redis://localhost:6379')
installRedis(redis)That swaps the default in-memory broadcast transport for one backed by Redis Pub/Sub. All subscribers across the cluster observe the same publish order for a given key.
Sharing an existing client
Pass an existing ioredis Redis or Cluster instance when you want to share a connection or set custom options such as TLS or a retry strategy.
// Environment: server
import IORedis from 'ioredis'
import { installRedis } from '@telefunc/redis'
const redis = new IORedis(process.env.REDIS_URL, { tls: {} })
installRedis(redis)Internally, Telefunc calls duplicate() on the client to open a dedicated subscriber connection — your instance is never mutated or disconnected. You can continue to use it alongside Telefunc without interference.
Channels
Channel is per-instance. Reconnects must land on the instance holding the channel's state, so multi-instance deployments need sticky sessions at the load balancer. See Stream at Scale.