Skip to content

Conversation

YSK-06
Copy link

@YSK-06 YSK-06 commented Sep 8, 2025

Add Redis Cache Connector with TTL, Namespacing, Retry Support, and Demo Agent
📌 Summary

This PR introduces a Redis cache connector for SmythOS SRE projects along with a demo AI agent that shows cache hit/miss behavior in practice.

✨ Features

set/get/del/keys/flushNamespace/quit API

JSON auto-serialization & parsing

TTL support (per key + global default)

Namespacing to prevent collisions across agents

Retries with exponential backoff for reliability

TLS support (rediss:// or REDIS_TLS=true)

Demo AI Agent that wraps an LLM (OpenAI, Google Gemini, or mock fallback) and logs [CACHE MISS] and [CACHE HIT]

✅ Verification Steps

Start Redis locally:

npm run redis:up
npm run redis:ping # expect "PONG"

Run connector smoke check:

npm run redis:cache-check

Expected output:

get(hello) -> world
get(obj) -> { a: 1, b: 'x' }
keys(*) -> [...]
after del(hello) -> null
✅ Connector smoke passed

Run automated tests:

npm run test:redis

✅ All 5 tests pass

Run the AI agent demo:

npm run agent:demo:prompt

Example output:

[CACHE MISS] key=demo-llm:... → querying model...
[CACHE STORE] key=demo-llm:... → saved with TTL=120s
OUT 1: ...

[CACHE HIT] key=demo-llm:...
OUT 2: ...
✅ Demo complete (second call faster due to cache)

🧪 Test Coverage

String roundtrip

TTL expiration behavior

JSON object storage/retrieval

keys() returns namespaced keys

del() removes items

📂 Folder Structure
src/
connectors/
redis/
index.ts # main connector
utils/
retry.ts # retry/backoff helper
agents/
cached-llm.ts # Redis-cached LLM wrapper
adapters.ts # OpenAI, Google, Mock adapters
scripts/
redis-cache-check.ts # smoke test
demo-agent.ts # demo agent with cache
test/
redis.test.ts # automated tests

Redis cache connector for SmythOS SRE projects.
It provides a simple, typed API for caching with TTL, namespacing, retry logic, and TLS support
Copy link

coderabbitai bot commented Sep 8, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant