Skip to content

Comments

Feat: Implements Redis database backend #218

Merged
Oxazolidinone merged 6 commits intomainfrom
feat-implements-redis
Aug 21, 2025
Merged

Feat: Implements Redis database backend #218
Oxazolidinone merged 6 commits intomainfrom
feat-implements-redis

Conversation

@Oxazolidinone
Copy link
Contributor

PR Description: Add Redis Vector Storage Backend

Summary

This PR adds a Redis backend for the vector storage system, enabling scalable, high-performance similarity search using Redis Stack with RediSearch. It supports multiple distance metrics, robust error handling, and workspace-specific configuration.

Usage

Using Docker (local host)

docker run -d --name redis-vector-db -p 6379:6379 redis/redis-stack-server:latest

Enviroment configuration

VECTOR_STORE_TYPE=redis
VECTOR_STORE_DISTANCE=cosine
VECTOR_STORE_COLLECTION=vector-storage-memory
REDIS_DATABASE=0

# Option 1: Use URL (works for both local & cloud)
#   - redis://  → no SSL (local)
#   - rediss:// → SSL/TLS (Redis Cloud)
VECTOR_STORE_URL=rediss://default:<password>@<host>:<port>

# Option 2: Use host/port (works for both local & cloud)
VECTOR_STORE_HOST=<host>
VECTOR_STORE_PORT=<port>
VECTOR_STORE_PASSWORD=<password>
VECTOR_STORE_USERNAME=<username>

Features

  • Core Backend Implementation
    • RedisBackend class implementing the VectorStore interface
    • Supports distance metrics: COSINE, L2 (Euclidean), IP (Inner Product)
    • RediSearch-powered vector indexing and querying
    • Workspace and global configuration support
    • Automatic distance metric normalization for enum validation
  • Data Persistence
    • Vectors and metadata stored in Redis JSON documents
    • Collection management via RediSearch indices
    • Atomic operations for insert, update, delete
  • Search Capabilities
    • KNN similarity search with configurable result limits
    • Distance-based scoring per metric
    • Metadata filters (range operators: gte, lte, gt, lt, any)
    • Pagination and sorting support
  • Configuration Integration
    • Environment variable support for all Redis connection options
    • Zod schema validation for config
    • Factory integration for backend selection and workspace fallback
    • Default configuration with sensible defaults

Testing

  • Unit tests for connect, insert, search, update, delete, and list operations
  • Metric-specific tests for COSINE, L2, and IP scoring
  • Error handling tests for invalid operations and connection issues
  • Filter support tests: range queries, any filters
  • Mock implementations for Redis client and RediSearch interactions

@willingWill17
Copy link
Collaborator

The Redis instance contains 16 separate databases, numbered from 0 to 15. However, database 0 failed to initialize. Please also verify the database separation, as the mentioned database remained empty even after data was saved.

@Oxazolidinone Oxazolidinone merged commit e5c5c9f into main Aug 21, 2025
5 checks passed
@willingWill17 willingWill17 deleted the feat-implements-redis branch August 21, 2025 17:17
Ptah-CT pushed a commit to DerAuctor/ct-cipher that referenced this pull request Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants