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
Since the question has
laravel
in the tag, I recommend the ready-made solution, https://github.com/dingo/api. This package has a featureRate 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