Closed gmansilla closed 7 years ago
For those having the same problem I had:
1) The handler id is a reference to an actual Service defined in your services.yml file.
2) Since this bundle is a wrapper for the [Memcached] class you can either extend it or use the base class.
That being said, you could do something like
my.memcached.service:
class: Memcached
calls:
- [addServer, ['memcached_address', 'memcached_port']]
my.memcached.session.handler:
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler
arguments:
- "@my.memcached.service"
- prefix: 'your_prefix'
- expiretime: 'your_expire_time'
@gmansilla Note that that session handler does not implement locking.
Right, so if you want to have locking available you must replace
"Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler" with "Lsw\MemcacheBundle\Session\Storage\LockingSessionHandler".
I think this is worth mentioning in the README file. Should I create PR for this?
Yes.. good idea.. although I won't be the one merging it.
Fair enough. I'll create the PR.
In my case, I have multiple instances of my app running behind a load balancer, that's why I wanted to save sessions in memcached in the first place.
What should I use as handler_id in config.yml? If I leave this null, then it'll use the default session handler from php.ini