perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wim Kerkhoff <>
Subject Re: memory usage / session cleanup
Date Fri, 19 Dec 2003 18:38:40 GMT
Hans de Groot wrote:

>Than an other question
>I installed embperl a while ago, with storable and apache session and made the
>session database.
>What is the properway to cleanup the session database? Right now I just delete
>the content of the session table but this also deletes the sessions of the
>current users, which is a it rude.
Here's what I do...

I'm using PostgreSQL to store the sessions.

In the sessions table, I added an extra column for stamp_inserted with 
type timestamp, in addition to the id and a_session fields.

I set the default on this timestamp column to be now(). Here's the DDL 
from pg_dump:

CREATE TABLE sessions (
    id character(32) NOT NULL,
    a_session text,
    stamp_inserted timestamp without time zone DEFAULT now()
    ADD CONSTRAINT sessions_pkey PRIMARY KEY (id);

Then, have a cronjob that runs a DBI script, with something like:

$dbh->do("delete from sessions where stamp_inserted <  now() - interval 
'2 days'")

You can't do this with MySQL, since it won't let you set a default value 
to a function, only a constant (null, 1, 'foo', etc).



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message