-
Notifications
You must be signed in to change notification settings - Fork 31
feat: Add Redis caching for navigation pagination #488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
5c8d201
to
8991cfc
Compare
b16cc88
to
8991cfc
Compare
|
||
if redis_enable: | ||
try: | ||
redis = await connect_redis() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
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 theREDIS
orREDIS_SENTINEL
environment variables. -
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()
-
Logging has been added for users.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, | ||
}, | ||
) | ||
|
There was a problem hiding this comment.
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, | ||
}, | ||
) | ||
|
There was a problem hiding this comment.
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
8991cfc
to
e3e84cd
Compare
- 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.
c88193b
to
ab22909
Compare
ab22909
to
c658023
Compare
Related Issue(s):
Description:
Add Redis caching support for navigation pagination to enable proper
prev
/next
links in STAC API responses.PR Checklist:
pre-commit run --all-files
)make test
)