hitcounter - Grails Page Counter -


I need to create a counter for some pages, so I create a domain named Counter:

 < Code> square counter {java.sql.Date date; Member member; integer number; Int submit; // Setter and Greater ...}   

Counts how often this page opens, and how many times the form is submitted (type of contact form).

And I created a service called Counter Service:

  class counter service {list counter; Def load () {counter = counter.findlist (new java.sql.date (System.currentTimeMillis ())); } Def increaseCount (member member) {counters.each {if (it.member.id = member.id) it.setCount (it.count + 1); }} // Rest of code ...}   

I will save the counter in the hourly database using the quartz job.

Do you think this counter variable is multilingual-protected? Since the CounterService will be called in many controllers I need to load before the server starts and I do not know where to call it. Do I have any suggestions on where to load ()? Or perhaps, a better solution for the page counter?

Why are you using java.sql .at ? Simple java.util.Date can do this with a low code overhead.

I will not use a plain map for this. I would like to use caching in hibernation:

  counter counter = counter Foundbyddt (some days, [cache: true]);   

so that the object is placed in the cache for 5 or 10 minutes (the default error code does not exactly remember the value)

There will be another option, If you really need all the counters at once, using ConcurrentHashMap for caching, which implements thread protection: CounterService {ConcurrentHashMap Counter ....}

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -