Skip to Content
Engineering11 Documentation 🔥

Redis API

Simplified Redis connection management with GCP project-based key namespacing.

What It Does

The Redis API provides a lightweight wrapper around Redis that simplifies connection management and provides utilities for batch key operations. It automatically namespaces keys by GCP project ID to prevent collisions in multi-tenant or multi-project environments.

Key Capabilities

CapabilityDescription
Singleton ConnectionManages single Redis client instance with connection pooling
Auto-ConfigurationRetrieves connection parameters from configuration service
GCP Project NamespacingAutomatic key prefixing by GCP project ID for isolation
Prefix-Based OperationsBatch purge and query operations by key prefix
Connection ManagementFactory pattern for creating and reusing connections
Testing SupportMock Redis for unit tests without real Redis instance

Configuration

Default Configuration

  • Host: localhost
  • Port: 6379
  • Key Prefix: GCP Project ID

Environment Variables

  • REDIS_HOST: Redis server hostname
  • REDIS_PORT: Redis server port
  • Configuration service provides these values

Exports

Classes

  • RedisConnectionFactory - Connection factory

Functions

  • purgeKeysWithPrefix() - Batch delete by prefix
  • getKeysWithPrefix() - Query keys by prefix

Common Use Cases

  • Cache management: Prefix-based cache invalidation
  • Session storage: Project-isolated session keys
  • Rate limiting: Project-specific rate limit counters
  • Multi-tenant caching: Isolated caches per tenant/project
  • Key discovery: Find related cached items
  • Batch cleanup: Delete groups of related keys

What Customers Don’t Have to Build

  • Redis connection factory
  • Singleton connection management
  • GCP project-based namespacing
  • Prefix-based batch operations
  • Configuration service integration
  • Connection pooling
  • Key prefix management
  • Pattern-based key discovery
  • Batch deletion logic
Last updated on