Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

periodic database purge - advice needed

  • 02-01-2012 06:09PM
    #1
    Registered Users, Registered Users 2 Posts: 1,180 ✭✭✭


    Hi i am currently creating a java server which stores user data in a mysql database. I would like to keep data somewhat fresh, so i was hoping that every 5 minutes, to have a thread poll the database, and remove any data from users which have been inactive in the past 5 minutes or so

    i just wondering what (experienced)peoples opinions are on an efficient way to do this. my idea was to have the thread sleep for 5 minutes before polling the DB again. is it possible to have a script in PL\SQL run every 5 minutes to do this?

    also will there be a contention issue for the database, i.e. what if the server is inputting data at the exact same time the purging thread is deleting data from the same table

    i am fairly good with java, however as you may notice i lack real world experience, so i'm open to all opinions :)


Comments

  • Registered Users, Registered Users 2, Paid Member Posts: 2,032 ✭✭✭lynchie


    Possibilities are

    java.util.concurrent.ScheduledThreadPoolExecutor
    java.util.Timer

    or use something more featured such as Quartz


  • Registered Users, Registered Users 2 Posts: 15,079 ✭✭✭✭Malice


    Is there a particular reason why you need to remove data at such short intervals? Could you read the user from the database, store it somewhere e.g. in a HTTP session and then wipe that instead?


Advertisement