search

Home  >  Q&A  >  body text

php - How to limit the flow of the api interface (not targeting IP, and users), how to implement

Just like the title.
Interface limits the number of accesses for the same user (device)

巴扎黑巴扎黑2718 days ago1923

reply all(1)I'll reply

  • 世界只因有你

    世界只因有你2017-06-22 11:55:06

    Since the question has laravel in the tag, I recommend the ready-made solution, https://github.com/dingo/api. This package has a feature Rate Limiting, which should be what you are looking for.

    If you want to implement it yourself, it is simple. Use [user_id + device unique code] as the primary key, store the number of visits in redis, record the number of visits, and then the specific frequency and number of times all depend on your implementation strategy

    reply
    0
  • Cancelreply