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

Caching mechanism #4

Open
dusan-turajlic opened this issue Jul 16, 2021 · 0 comments
Open

Caching mechanism #4

dusan-turajlic opened this issue Jul 16, 2021 · 0 comments

Comments

@dusan-turajlic
Copy link
Member

Is your feature request related to a problem? Please describe.
A caching mechanism would greatly improve how the API can be used. Then you could make lots of requests and always have them available in your cache. Not only that but the cache could actually fire events when it updates that way you can make use of other frameworks and software to live update data everywhere when it updates in the cache.

Describe the solution you'd like
A simple cache that can store the responses in an immutable form. Reason being that if the data is immutable ani mutations require you to create a new object, and that is good because that allows you to track changes in a very fine graned way.

Additional context
Its very important to create this because it will greatly reduce the number of requests that one needs to make to a sever. However, as with any caching mechanism, it's important to be able to work around it. My suggestion would be something like this.

await hyperMashmau.get<{name: string, age: number, gender: string}>(`/hm:users/0/{
  name,
  age,
  gender,
}`).force();

The .force() in the end would go around the cache and make an API request directly witch would then update the cache when the response comes back. Also follow HTTP2 spec for caching only GET and HEAD requests should be cached, POST, PUT, DELETE, etc should never be cached however there response can update the cache.

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

No branches or pull requests

1 participant