David Spades wrote:I saw that many people say linkedlist must be avoided (memory issue, etc), ...
David Spades wrote:I see. so for my operations:
1. add element always at the end
2. remove element always at the beginning
3. no iteration, no random access and no synchronization
LinkedList is best options in java 8, yes?
just want to make sure with those already using this impl if there's a better way or if linkedlist has undesirable side effects.
David Spades wrote:ok, so what I'm trying to do is "guard" a certain method with a certain access frequency.
lets say I want the method not be accessed more than 60 times within any 5-minute window. so everytime the method is accessed:
1. it will first get "now" timestamp
2. check if the timestamp diff of first access token in queue and "now" is MORE than 5 mins
3. if #2 condition is met, pop first access token, create new access token and push said access token
4. if #3 condition is not met, then sleep
David Spades wrote:your approach wont work for this case
max 5 requests in any 5-minute window
9.05 am --> violated
David Spades wrote:max 5 requests in any 5-minute window
there are 6 requests between 4.08am to 9.05 am (less than 5 minutes)