GithubHelp home page GithubHelp logo

Comments (10)

xaionaro avatar xaionaro commented on July 19, 2024 1

Why do you need lock that?

The processing without cache is quite expensive (and long) in my case. So if I receive 10 requests with the same URI then I should not run the processing 10 times, I should run it just once and just return the same result to all 10 requests.

If finally you will use fasthttp directly with router, I recommend you to use https://github.com/fasthttp/router instead fasthttprouter, because fasthttp team maintain this router (including me, who belong to the team).

OK. I will. Thank you :)

from atreugo.

xaionaro avatar xaionaro commented on July 19, 2024

A proposal: #38

from atreugo.

xaionaro avatar xaionaro commented on July 19, 2024

One more problem.

I need for After be always executed if a Before filter decides so. I suppose this is the reason why other frameworks wraps handlers in middlewares instead of making Before and After :)

from atreugo.

xaionaro avatar xaionaro commented on July 19, 2024

For me not actual, anymore. I decided to do not use atreugo. Too difficult to implement a caching middleware here :(

from atreugo.

savsgio avatar savsgio commented on July 19, 2024

Sorry, I have been bussy last days, I will review your PR, and merge it

from atreugo.

savsgio avatar savsgio commented on July 19, 2024

But why are you going to not use atreugo?
I think you shouldn't have too much difficults to use it.

You could share a bit of code with me and I could try to help you.

from atreugo.

savsgio avatar savsgio commented on July 19, 2024

Because you need to execute the before and after middlewares without execute the view, right?

Is the view response save on cache?

from atreugo.

xaionaro avatar xaionaro commented on July 19, 2024

I will review your PR, and merge it

The PR breaks current API, so it is very understandable if you will decide not to merge it :)

Because you need to execute the before and after middlewares without execute the view, right?

I've switched to fasthttprouter. Here's the result (a working middleware):

https://github.com/xaionaro-go/picapi/blob/ca37babf5db8ffc5ad2ed026fa1e29d843c56303/httpserver/middlewares/cache.go#L81

c.NextHandler(ctx) executes a view. I cannot make the same on atreugo due to two problems:

  1. I cannot prevent the execution of the view, like in line 77. My PR solves this problem.
  2. I cannot make a lock like in line 66. My PR doesn't solve this problem.

from atreugo.

savsgio avatar savsgio commented on July 19, 2024
  1. I will think some methods to encourage that.
  2. Why do you need lock that?

from atreugo.

savsgio avatar savsgio commented on July 19, 2024

If finally you will use fasthttp directly with router, I recommend you to use https://github.com/fasthttp/router instead fasthttprouter, because fasthttp team maintain this router (including me, who belong to the team).

The router has some enhancements and improve performances with respect original package

from atreugo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.