[dancer-users] Session Management with memcached in Dancer1

Andrew Solomon andrew at geekuni.com
Wed Apr 15 23:16:41 BST 2015


Bill,

Once a website with cookies is in production it needs caching systems like
Memcached or Redis for key-value data storage where you can access the data
from different processes. In development one usually only runs a single
process, but in production you'll normally want several processes to be
running so that you can have lots of users visiting your site
simultaneously. If you don't have a separate caching system then when user
gets a cookie (e.g. logs in) with Process A then clicks on a link and that
request winds up with Process B, it won't have access to the session data
stored in Process A, and will think that the user's cookie is invalid.

Tushar

You're right that you need to install the memcached server for
Dancer::Session::Memcached
to work. The config line you're referring to

memcached_servers: "10.0.1.31:11211,10.0.1.32:11211,10.0.1.33:11211
,/var/sock/memcached"

is just an example of how you communicate to Dancer how you've setup
memcached. In this case you're saying - I've got a memcached daemon setup
on boxes with IP addresses 10.0.1.31-33 all accessible on port 11211, and
it's also running on the localhost and you should access it by writing to
the socket /var/sock/memcached.

For an explanation of memcached with multiple servers, read the answer
starting with 'when you set several servers...'

http://stackoverflow.com/questions/352536/how-to-link-memcached-server-together

To see what I mean by 'socket' in reference to "/var/sock/memcached"  see
the 'Socket' section here:

http://en.wikipedia.org/wiki/Unix_file_types

I think the default of memcached_servers is 127.0.0.1:11211 (i.e
localhost). That is, if you've got a single box in production with multiple
processes and one memcached on the same box, you don't need a
memcached_servers entry in the Dancer config file. [Experts, please correct
me if I'm wrong since I've only done this with Dancer2]

I hope that clears things up, and if not please say so!

Andrew



On Wed, Apr 15, 2015 at 4:01 PM, William Carr <bill at bottlenose-wine.com>
wrote:

> Hi,
>
> I’ve been using Dancer::Session::Cookie but not in production yet. You
> don’t have to setup a “session server” with this approach.
>
>
> On Apr 15, 2015, at 10:33 AM, Tushar Dave <tushardave26 at gmail.com> wrote:
>
> Hello All,
>
> I am trying to learn session management in Dancer. I have consulted
> Dancer::Session documentation for the same. The document recommends to use
> memcached server for production and YAML or Simple for development. My
> question is specifically related to memcached server. Do I need to setup
> the memcached server on the system before using Dancer::Session::Memcached?
> Also, what does this "/var/sock/memcached" mean in the
> Dancer::Session::Memcached documentation (I believe it is the default
> location of memcached server after installation on local system)?
>
> I am sorry if my question is to silly. But I am trying to understand the
> right procedure.
>
> Thanks for the help.
>
> Best,
> Tushar Dave
>
>  _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
>
>  <http://www.bottlenose-wine.com/>
> Bill Carr, President at Bottlenose
> (413) 584-0400
> http://www.bottlenose-wine.com
>  Download vCard <http://www.bottlenose-wine.com/vcard/BillCarr.vcf>
>
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
>


-- 
Andrew Solomon

Mentor at Geekuni http://geekuni.com/
http://www.linkedin.com/in/asolomon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150415/a01fc83b/attachment.html>


More information about the dancer-users mailing list