java - A little confused about access count -


now responsibility in project access count module. if user login in 2 hours repeatly ,it should treat once.

i use concurrenthashmap put user id , access time.

private static map<string,date> logintimemap = new concurrenthashmap<string, date>(); 

every time user access index page , program compare time.

date date = logintimemap.get(user.getsuuserid()); if(date==null||dateutil.gethourinterval(new date(),date)>=definedvalue.limit_time){     accesscount=accesscount+1;     logintimemap.put(user.getsuuserid(), new date()); } 

in code limit_time constant refers 2 hours.

will logintimemap slow server if size of map exceed 10000?

really sorry poor english!

will logintimemap slow server if size of map exceed 10000?

a hashmap has time complexity of o(1). is, hashes, goes straight value. not search value. means it's performance not proportional amount of elements in array, although 10,000 entries might memory heavy!


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -