On 05/02/2014 10:07 PM, Maxwell Carey wrote:
> 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?
> 

It makes a lot of sense to lock sessions, in any session backend (not only file 
based). Locking file based sessions
isn't a big deal.

Regards
        Racke


-- 
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team

_______________________________________________
dancer-users mailing list
[email protected]
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

Reply via email to