[dancer-users] Lock session files with Dancer2::Session::YAML?
Maxwell Carey
mcarey at ucar.edu
Fri May 2 21:07:02 BST 2014
Is it possible to lock session files created by Dancer2::Session::YAML
in order to avoid race conditions when two processes try to write to the
same session at the same time? For example, if I have the following routes:
get '/foo' => sub {
my $foo = session 'foo';
session 'foo' => ++$foo;
};
get '/bar' => sub {
my $bar = session 'bar';
session 'bar' => ++$bar;
};
and both are called at the same time, one route "wins", resulting in
either the value of 'foo' or 'bar' being updated, but not both.
If it's not possible (or easy) to lock the file, I would be open to an
alternative storage backend, although I was hoping to keep things as
simple as possible, i.e. I don't want to have to spin up a new MySQL
database or equivalent. The existing Dancer2::Session:: backends all
seem somewhat...involved. Any ideas?
More information about the dancer-users
mailing list