Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Cleaning Up Apache::Session data

by iguanodon (Curate)
on Mar 31, 2003 at 02:51 UTC ( #246839=note: print w/ replies, xml ) Need Help??


in reply to Cleaning Up Apache::Session data

I do exactly what you describe. I use Apache::Session with an Oracle back end, and a trigger updates a 'last used time' column. Then I run a cron job to delete sessions older than a given number of days. I find it useful to leave the sessions around for a few days so I can look at them to troubleshoot problems.

The automatic updating of TIMESTAMP columns is a MySQL thing, it's not part of the Apache::Session code. I haven't used PostgreSQL in a while, so I can't remember if the equivalent functionality exists.


Comment on Re: Cleaning Up Apache::Session data
Re: Re: Cleaning Up Apache::Session data
by dga (Hermit) on Mar 31, 2003 at 17:02 UTC

    In PostgreSQL

    ALTER TABLE tablename ADD COLUMN ts timestamp; ALTER TABLE tablename ALTER COLUMN ts SET DEFAULT CURRENT_TIMESTAMP;

    This will add a column which will get the time of the transaction on every insert automatically.

    You should use table and column names appropriate to your situation of course, also, if you are making the table you can pop the default in when you define the column like so.

    CREATE TABLE tablename ( ..., ts timestamp DEFAULT CURRENT_TIMESTAMP, +... );

    The insert needs to be  INSERT INTO tablename ( col1, col2 ) VALUES ( ?, ? ); rather than one which does INSERT INTO tablename VALUES ( ?, ? ); otherwise you will have a column count mismatch.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://246839]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2014-08-30 21:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls