Mojo Wonk Blog.

A semi-offical blog dedicated to the Mojolicious web framework

Day 2: The Stash

leather bag

In Mojolicious, when processing a request and preparing a response one of the most important concepts is "the stash". Since it is a non-blocking framework, your code can't use global variables to store any state during processing. If you did and some other code were to run, it could very easily get cross-talk between requests.

The stash is the place you can store information while you process it. It is just a simple hash reference that is attached to the controller object that is processing the request. It lives and dies with that one transaction.

While you can and should use it as a scratchpad, it really is much more. The stash controls almost every aspect of the response that you generate. Let's look a little closer to see how it works

Continue reading Day 2: The Stash...

Day 1: Getting Started

hot air ballons

Start at the Beginning

In this Advent Calendar series, some posts will be introductory, some will be advanced, some will be on new features. Who knows what could be next? But for now let's ensure a level playing field by working out how to get started.

Continue reading Day 1: Getting Started...