You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Wim Kerkhoff <wi...@nyetwork.org> on 2003/12/19 19:38:40 UTC
Re: memory usage / session cleanup
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()
);
ALTER TABLE ONLY sessions
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).
HTH,
Wim
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: memory usage / session cleanup
Posted by Wim Kerkhoff <wi...@nyetwork.org>.
Pierre Etchemaite wrote:
>Le Fri, 19 Dec 2003 10:38:40 -0800, Wim Kerkhoff <wi...@nyetwork.org> a écrit
>:
>
>
>
>>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).
>>
>>
>
>For MySQL, it seems that the way to go are TIMESTAMP fields:
>
>http://www.mysql.com/doc/en/DATETIME.html
>
>Those will be updated each time the record is, but in this case this looks
>appropriate.
>
>
Ok, thanks for the clarification. Pg's handling of default values,
triggers, etc still seems way better, IMO :-)
Wim
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: memory usage / session cleanup
Posted by Pierre Etchemaite <pe...@concept-micro.com>.
Le Fri, 19 Dec 2003 10:38:40 -0800, Wim Kerkhoff <wi...@nyetwork.org> a écrit
:
> 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).
For MySQL, it seems that the way to go are TIMESTAMP fields:
http://www.mysql.com/doc/en/DATETIME.html
Those will be updated each time the record is, but in this case this looks
appropriate.
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org