Return-Path: Delivered-To: apmail-perl-modperl-archive@www.apache.org Received: (qmail 14628 invoked from network); 27 Apr 2006 15:38:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 27 Apr 2006 15:38:56 -0000 Received: (qmail 54161 invoked by uid 500); 27 Apr 2006 15:38:48 -0000 Delivered-To: apmail-perl-modperl-archive@perl.apache.org Received: (qmail 54147 invoked by uid 500); 27 Apr 2006 15:38:48 -0000 Mailing-List: contact modperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list modperl@perl.apache.org Received: (qmail 54136 invoked by uid 99); 27 Apr 2006 15:38:48 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Apr 2006 08:38:48 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of ceeshek@gmail.com designates 64.233.166.178 as permitted sender) Received: from [64.233.166.178] (HELO pproxy.gmail.com) (64.233.166.178) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Apr 2006 08:38:47 -0700 Received: by pproxy.gmail.com with SMTP id w49so1102514pyg for ; Thu, 27 Apr 2006 08:38:27 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ODtDbhhed6JnAabAihdnaq2k/tELnvNBhrYQ2lYKzEzRxjUv76Ar9fk8OampTXTZ9PVp8DYnD+AteAuRoIOYZexOAN0PnRy44ccUvzXjmwBA2Ph/JAYUwmuQ5GRL28K5J+bei5Datw5t07plZmJVrVwsf3zyn0oDZGZ1vkRH4D8= Received: by 10.35.123.2 with SMTP id a2mr72362pyn; Thu, 27 Apr 2006 08:38:25 -0700 (PDT) Received: by 10.35.60.12 with HTTP; Thu, 27 Apr 2006 08:38:25 -0700 (PDT) Message-ID: Date: Thu, 27 Apr 2006 11:38:25 -0400 From: "Cees Hek" To: ichudov@algebra.com Subject: Re: Apache::Session: can I have a "date" in session Cc: "Mod_Perl Mailing List" In-Reply-To: <20060427152050.GA3339@manifold.algebra.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20060427152050.GA3339@manifold.algebra.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On 4/27/06, Igor Chudov wrote: > I run algebra.com with a few thousand registered users and a lot more > unregistered. I use Apache::Session to store their session info. Right > now I clean sessions every month. I would like to be smarter and clean > sessions based on date information (ie remove sessions that are more > than 3 weeks old). > > Can I have a date as a relational column in the sessions table? > > I know that I could maintain a date in the session data blob, but, it > is expensive to use that for a few reasons. You can have the database do all that for you using a trigger (if your database suports it). I have used PostgreSQL in the past to do the following: CREATE TABLE sessions ( id varchar(32) NOT NULL PRIMARY KEY, a_session text NOT NULL, lm timestamp with time zone DEFAULT now() ); CREATE FUNCTION update_session_lm() RETURNS "trigger" AS ' BEGIN NEW.lm :=3D ''now''; RETURN NEW; END; ' LANGUAGE plpgsql; CREATE TRIGGER update_session_lm_trig BEFORE UPDATE ON sessions FOR EACH ROW EXECUTE PROCEDURE update_session_lm(); The deleting the sessions becomes a simple SQL statement against the lm column. And this requires no code changes as everything is handled in the database. There is always a trade off though. This means more load up front when the sessions are created and/or altered. The database has to do slightly more work on each request to make the expiring of sessions easy for you in the end. Cheers, Cees