Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Cleaning Up Apache::Session data

by iguanodon (Priest)
on Mar 31, 2003 at 02:51 UTC ( [id://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.

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://246839]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-25 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found