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

Add a cache layer for preventing larger no of read request to the server #490

Open
Rupeshiya opened this issue Jul 3, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@Rupeshiya
Copy link
Contributor

Present scenario:
As of now no cache layer is there, on get/link request the link is directly fetched from db

Expected scenario:
As the Kutt is the read heavy platform so it's better to make a cache layer and check the cache layer for the data requested by the client side before sending the request to the server which will reduce the server load

@poeti8 Please let me know your thoughts

@poeti8
Copy link
Member

poeti8 commented Jul 3, 2021

There's a cache layer. Look at where Redis is used. But not that extensive though.

@Rupeshiya
Copy link
Contributor Author

@poeti8 yes you are right.
But I think the url is directly getting fetched from db, it's not checking the cache.
Check /server/handler/link.ts


export const get: Handler = async (req, res) => {
  const { limit, skip, search, all } = req.query;
  const userId = req.user.id;

  const match = {
    ...(!all && { user_id: userId })
  };

  const [links, total] = await Promise.all([
    query.link.get(match, { limit, search, skip }),
    query.link.total(match, { search })
  ]);

  const data = links.map(utils.sanitize.link);

  return res.send({
    total,
    limit,
    skip,
    data
  });
};

Please correct me if I am wrong.

@poeti8
Copy link
Member

poeti8 commented Jul 5, 2021

That's correct, many of them are not cached.

@Rupeshiya
Copy link
Contributor Author

So Should I proceed ahead to fix this @poeti8 ?

@poeti8
Copy link
Member

poeti8 commented Jul 11, 2021

@Rupeshiya Sure!

@poeti8 poeti8 added the enhancement New feature or request label Jul 11, 2021
@Rupeshiya
Copy link
Contributor Author

@poeti8 This (#269 (comment)) is blocking me to proceed.
Can you please help me to resolve that so that I can contribute?

@poeti8
Copy link
Member

poeti8 commented Aug 28, 2021

@Rupeshiya Can't you use a temp mail host service like https://ethereal.email/?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants