Redis Config Store

@purista/redis-config-store stores config values as JSON strings in Redis. It is a good choice when Redis is already in your stack and you want a simple, fast config backend without additional infrastructure.

Capabilities

FeatureSupport
Read (getConfig)✅ (enabled by default)
Write (setConfig)✅ (opt-in)
Delete (removeConfig)✅ (opt-in)
Persistence across restarts✅ (Redis persistence)
TTL / expiryvia Redis directly
Cluster / Sentinel✅ (node-redis)

Install

npm install @purista/redis-config-store

Setup

import { RedisConfigStore } from '@purista/redis-config-store'

const configStore = new RedisConfigStore({
  config: {
    url: process.env.REDIS_URL ?? 'redis://localhost:6379',
  },
  // By default only reads are enabled.
  // Enable writes and deletes explicitly when your services need them:
  enableSet: true,
  enableRemove: true,
})

const myService = await myV1Service.getInstance(eventBridge, { configStore })

The config object is passed directly to node-redis — all connection options (TLS, authentication, cluster, Sentinel) are supported.

Usage inside a handler

.setCommandFunction(async function (context, payload) {
  // Read one or more keys — returns a keyed object
  const { apiBaseUrl, retryLimit } = await context.configs.getConfig('apiBaseUrl', 'retryLimit')

  // Write a value at runtime
  await context.configs.setConfig('featureFlags', { newCheckout: true })

  // Remove a key
  await context.configs.removeConfig('deprecatedKey')
})

Feature flags

enableGet: true,     // allow reading  (default: true)
enableSet: true,     // allow writing  (default: false)
enableRemove: true,  // allow deleting (default: false)

Disable write operations on services that should only read config to enforce least-privilege at the application layer.

Operational tips

  • Store config under a consistent key prefix per environment (prod:config:, staging:config:) to avoid collisions
  • Enable Redis persistence (RDB or AOF) so values survive broker restarts
  • Use Redis ACLs to restrict which services can write to the config namespace
  • The Redis connection is established lazily on first use; connection errors are logged with full span context