Skip to content

Conversation

YuriZmytrakov
Copy link
Collaborator

@YuriZmytrakov YuriZmytrakov commented Oct 8, 2025

Related Issue(s):

Description:

Add Redis caching support for navigation pagination to enable proper prev/next links in STAC API responses.

PR Checklist:

  • Code is formatted and linted (run pre-commit run --all-files)
  • Tests pass (run make test)
  • Documentation has been updated to reflect changes, if applicable
  • Changes are added to the changelog

@YuriZmytrakov YuriZmytrakov force-pushed the CAT-1382-2 branch 9 times, most recently from 5c8d201 to 8991cfc Compare October 8, 2025 13:07
@YuriZmytrakov YuriZmytrakov changed the title feat: add redis cache for navigation feat: Add Redis caching for navigation pagination Oct 8, 2025
@YuriZmytrakov YuriZmytrakov force-pushed the CAT-1382-2 branch 2 times, most recently from b16cc88 to 8991cfc Compare October 8, 2025 13:30

if redis_enable:
try:
redis = await connect_redis()
Copy link
Collaborator

Choose a reason for hiding this comment

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

how does this work with connect_redis_sentinel?

Copy link
Collaborator

Choose a reason for hiding this comment

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

there is connect_redis and connect_redis_sentinel. I think maybe there is logic missing which should determine which one to use? Maybe you can explain how it works?

Copy link
Collaborator

Choose a reason for hiding this comment

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

we should also log the redis connection whether its successful or not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. If a user wants to use standalone Redis (the most common case), they should use connect_redis(). If they want to use Redis Sentinel (used by Cloudferro), connect_redis_sentinel() should be used. The connection is configured differently in each case, which is why we have two separate functions. The user needs to configure either the REDIS or REDIS_SENTINEL environment variables.

  2. The selection of which function to use should be done in redis_utils.py:

    • For standalone Redis: redis_settings: BaseSettings = RedisSettings()
    • For Redis Sentinel: redis_settings: BaseSettings = RedisSentinelSettings()
  3. Logging has been added for users.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok thanks for explaining - here you only use connect_redis but should you use connect_redis_sentinel as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the user configures Redis Sentinel, the connect_redis_sentinel function should be used instead of connect_redis. I could try to combine these two functions into one, which would choose the appropriate approach depending on whether the user wants standalone or Sentinel depending on config selected. This way, no one would need to manually replace function, only connect_redis would be called. Both approaches are fine with me. Just to note, Cloudferro will probably be the only users of Sentinel, which is why I added this function.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good idea, maybe even a helper function that calls the right function. If there are env options for sentinel in the codebase then we have to make it useable. Never say never.

"href": prev_link,
},
)

Copy link
Collaborator

@jonhealy1 jonhealy1 Oct 10, 2025

Choose a reason for hiding this comment

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

can this code - the redis_enabled block - be put into a function? It is used with all_collections too

"href": prev_link,
},
)

Copy link
Collaborator

Choose a reason for hiding this comment

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

this code into a function

Yuri Zmytrakov added 3 commits October 10, 2025 14:18
- Configure Redis image for tests of caching navigation
- Update Make file Redis with test targets for ES and OS
- Integrate Redis/Redis Sentinel client to cache navigation
- Add Redis funcs Sentinel for navigation caching
Add tests for Redis pagination caching in search and collections endpoints, plus utility function tests.
@YuriZmytrakov YuriZmytrakov force-pushed the CAT-1382-2 branch 3 times, most recently from c88193b to ab22909 Compare October 10, 2025 13:23
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