[dancer-users] session() auto-flush

Naveed Massjouni naveed at vt.edu
Fri Feb 14 19:35:32 GMT 2014

On Fri, Feb 14, 2014 at 2:26 PM, David Golden <xdg at xdg.me> wrote:
> On Fri, Feb 14, 2014 at 1:41 PM, Warren Young <warren at etr-usa.com> wrote:
>>     session()->{b} = 2;
> I agree in principle with most everything you say, except for this
> above.  You're violating encapsulation by modifying the internals of
> the object.  As soon as you do that, you break the API contract and
> so, yes, mayhem results.
> The fact that the object doesn't give you a useful API for direct
> modification is a flaw in the API, but going around it and expecting
> it to just "magically work" isn't really right.
> I would have no objection to having get/set methods added to
> Dancer::Session::Abstract to allow you to modify keys.  At the moment,
> modification would need to also trigger a flush.  Or, the API needs to
> document that you need to flush as soon as you're done modifying.

Doesn't D1's Session interface already provide get/set via
And it seems to automatically do a flush after a write (unless is_lazy is set).


> I'd also be happy to see work done to defer flushing until after the
> request is handled (as D2 does).  But someone has to do that work.
> And that might have unintentional side effects, I'd say that the eager
> flushing when setting variables might have been an intentional
> compensation for the race condition inherent in session
> loading/saving.
> David
> --
> David Golden <xdg at xdg.me>
> Take back your inbox! → http://www.bunchmail.com/
> Twitter/IRC: @xdg
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

More information about the dancer-users mailing list