Skip to content
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

endpoint caching with redis #28

Closed
wants to merge 14 commits into from

Conversation

chinathaip
Copy link
Contributor

@chinathaip chinathaip commented Jan 13, 2024

Create a middleware that attempts to get cached data using URL path as key,

if data is found, simply return it
if not, retrieve data from the source and cache it (expires after 1 week)

@chinathaip chinathaip marked this pull request as draft January 13, 2024 05:37
import { createClient } from "redis";

const redisClient = createClient({
url: process.env.REDIS_URL
Copy link
Contributor

Choose a reason for hiding this comment

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

ohh is this connection with redis via url?

Copy link
Contributor Author

@chinathaip chinathaip Jan 13, 2024

Choose a reason for hiding this comment

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

yup, although I saw you configure with additional stuff like tls key cert ca. Should I do the same? and can you give me the url for the site you took references from?

Copy link
Contributor

Choose a reason for hiding this comment

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

actually i did it as like in the redis documentation, but i saw people do like this "url" thing too. I think it's better way since you don't really need to config stuff like port and host and password?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well.. a url is basically put everything in one line XD

redis://<username>:<password>@<host>:<port>

Copy link
Contributor

Choose a reason for hiding this comment

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

yup, although I saw you configure with additional stuff like tls key cert ca. Should I do the same? and can you give me the url for the site you took references from?

Isn't the TLS, Cert, CA and Key thing for SSL? If the service needs to go through SSL, wouldn't it need that configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it need to go through SSL? It's an internal docker network anyway though

redis://USERNAME:PASSWORD@redis:6379

@chinathaip chinathaip self-assigned this Jan 15, 2024
@chinathaip chinathaip deleted the branch khing/get-courses January 15, 2024 14:09
@chinathaip chinathaip closed this Jan 15, 2024
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.

3 participants