session_duration not used in set
rdfield opened this issue · comments
When using the setting session_duration in the environment file it isn't being passed through to the Cache::Memcached->set when the flush method is called.
Example environment settings:
engines:
session:
Memcached:
cookie_name: dancer2_cookie
is_http_only: 1
is_secure: 1
session_duration: 3600
memcached_servers:
- 127.0.0.1:11211
When SessionFactory calls _flush in Dancer2::Session::Memcached it only supplies the key and value. When the Dancer2:Session::Memcached object is created $self->session_duration is set correctly, but it isn't used.
Adding an extra line that appends the exptime parameter to the $self->memcached->set(@) call makes sure the session expires at the right time, e.g.
sub _flush {
my ($self) = shift;
croak "Memcache cluster unreachable _flush"
if $self->fatal_cluster_unreachable && not keys %{$self->_memcached->stats(['misc'])};
# append session_duration if set
push @_, $self->session_duration if $self->session_duration and $#_ < 2;
return $self->_memcached->set( @_ );
}