Skip to content

fix: use node-redis style TTL with factory adapter (fixes #16)#30

Closed
mrjasonroy wants to merge 1 commit intomainfrom
fix/pr28-node-redis-ttl-with-adapter
Closed

fix: use node-redis style TTL with factory adapter (fixes #16)#30
mrjasonroy wants to merge 1 commit intomainfrom
fix/pr28-node-redis-ttl-with-adapter

Conversation

@mrjasonroy
Copy link
Owner

Summary

  • Changes RedisClient interface's set() method to use node-redis style options ({ EX: seconds }) instead of ioredis positional args
  • Updates the factory adapter in createRedisAdapter() to translate { EX: seconds } to ioredis's "EX", seconds format
  • Updates tests to verify node-redis style TTL passing

This is a reworked version of #28 that properly handles the adapter layer. The original PR only changed redis.ts but didn't update the factory adapter, which would have broken TTL for users going through createCacheHandler().

Closes #16
Supersedes #28

Test plan

  • All 90 tests pass
  • TTL test verifies { EX: seconds } style args
  • Lint, format, typecheck all pass
  • Verify with node-redis client directly (manual)

🤖 Generated with Claude Code

The RedisClient interface now uses node-redis style SET options
({ EX: seconds }) instead of ioredis positional args. The factory
adapter translates these to ioredis's positional format ("EX", seconds).
Fixes #16.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @mrjasonroy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the Redis caching mechanism to standardize how Time-To-Live (TTL) values are passed to the Redis client. By adopting the node-redis style { EX: seconds } option object, it improves consistency and maintainability across the caching layer. The changes ensure that both the internal RedisClient interface and the ioredis adapter correctly process TTL, resolving a previous issue where TTL might not have been applied as expected for certain configurations.

Highlights

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • packages/cache-handler/src/data-cache/factory.ts
    • Modified createRedisAdapter to correctly translate node-redis style set options ({ EX: seconds }) to ioredis's positional arguments ("EX", seconds).
    • Updated JSDoc comments to reflect the new translation logic for node-redis style options.
  • packages/cache-handler/src/data-cache/redis.test.ts
    • Updated FakeRedis mock to correctly interpret node-redis style { EX: seconds } options for TTL calculation.
    • Adjusted existing TTL tests to assert against the new { EX: seconds } argument format when calling redis.set.
    • Renamed a test description from 'ioredis style args' to 'node-redis style options' for clarity.
  • packages/cache-handler/src/data-cache/redis.ts
    • Updated comments and interface descriptions for RedisDataCacheHandlerOptions and RedisClient to clarify compatibility with node-redis style options.
    • Changed the redis.set call within createRedisDataCacheHandler to pass TTL using the { EX: seconds } object format.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully refactors the Redis client interface and its usage to adopt a node-redis style for setting TTL (Time To Live) options. The RedisClient interface now expects an options object { EX: seconds } for its set method, which aligns with modern Redis client libraries. The createRedisAdapter function correctly translates these node-redis style options into ioredis positional arguments, ensuring backward compatibility with ioredis clients. The test suite has been thoroughly updated to reflect these changes, including modifications to the FakeRedis implementation and test expectations. This is a well-executed change that improves consistency and maintainability.

@mrjasonroy
Copy link
Owner Author

Closing in favor of pushing updates directly to #28

@mrjasonroy mrjasonroy closed this Feb 24, 2026
@mrjasonroy mrjasonroy deleted the fix/pr28-node-redis-ttl-with-adapter branch February 24, 2026 19:18
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.

TTL not working with node-redis cluster

1 participant