Subject: | Feature request: send session etime to driver->store() |
Date: | Sun, 8 Nov 2009 00:17:05 +0600 |
To: | bug-CGI-Session [...] rt.cpan.org |
From: | "Pavel V. Rochnyack" <rpv [...] nikolas.ru> |
Hi all!
I want to propose a new feature: allow get session expire time in
driver module. This allow to remove expired sessions from storage
without loading them, or will be very useful then storing sessions
in memcached. Patch can look like example below:
--- CGI/Session.pm.orig<--->2009-03-21 07:59:06.000000000 +0600
+++ CGI/Session.pm<>2009-11-07 23:35:51.000000000 +0600
@@ -250,7 +250,9 @@
unless ( defined $datastr ) {
return $self->set_error( "flush(): couldn't freeze data: " . $serializer->errstr );
}
- defined( $driver->store($self->id, $datastr) ) or
+ my $etime = undef;
+ $etime = time() + $self->{_DATA}->{_SESSION_ETIME} if ($self->{_DATA}->{_SESSION_ETIME});
+ defined( $driver->store($self->id, $datastr, $etime) ) or
return $self->set_error( "flush(): couldn't store datastr: " . $driver->errstr);
$self->_unset_status(STATUS_NEW | STATUS_MODIFIED);
}
Feature usage example:
driver_memcached.patch [----] 0 L:[ 1+ 0 1/ 18] *(0 / 483b)= - 45 0x2D
--- CGI/Session/Driver/memcached.pm.orig<->2009-09-11 18:19:22.000000000 +0700
+++ CGI/Session/Driver/memcached.pm<------>2009-11-07 23:24:16.000000000 +0600
@@ -35,12 +35,12 @@
.
sub store {
my $self = shift;
- my ($sid, $datastr) = @_;
+ my ($sid, $datastr,$etime) = @_;
croak "store(): usage error" unless $sid && $datastr;
.
#warn "store(): sid=$sid, $datastr\n";
my $memcached = $self->{Memcached};
- $memcached->set($sid, $datastr);
+ $memcached->set($sid, $datastr,$etime);
.
return 1;
}
--
Best regards,
Pavel V. Rochnyack mailto:rpv@nikolas.ru