← All insightsIntegration

How to use Vector Databases with Redis

CodeWizard Academy · 5 April 2025 · 3 min read · Intermediate

Vector Databases and Redis are a common pairing in a modern DevOps stack. Here is how they fit together and a practical way to wire them up.

Where Vector Databases fits

Vector databases store high-dimensional embeddings and retrieve the nearest neighbours to a query vector, powering retrieval-augmented generation (RAG), semantic search and recommendations. Popular options include Pinecone, Weaviate and Qdrant.

python
from qdrant_client import QdrantClient
from qdrant_client.models import Distance, VectorParams, PointStruct

c = QdrantClient('localhost', port=6333)
c.recreate_collection('docs', vectors_config=VectorParams(size=1536, distance=Distance.COSINE))
c.upsert('docs', [PointStruct(id=1, vector=emb, payload={'source': 'runbook'})])

Where Redis fits

Redis is an in-memory key-value store with rich data structures (strings, hashes, sorted sets, streams) used for caching, session storage, leaderboards, queues and rate limiting.

bash
# cache-aside with a 60s TTL
redis-cli SET user:42 '{...}' EX 60
redis-cli GET user:42
# fixed-window rate limit
redis-cli INCR rl:ip:1.2.3.4
redis-cli EXPIRE rl:ip:1.2.3.4 60

Making them work together

  • Keep the same embedding model for index and query
  • Combine vector search with metadata filters (hybrid search)
  • Set an eviction policy (e.g. allkeys-lru) and TTLs on cache keys
  • Use SCAN instead of KEYS in production

Want this pairing set up properly, with docs and handover? That is exactly the kind of work CodeWizard's embedded senior engineers do - and both Vector Databases and Redis have active community groups you can join for free.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult