Test Failed
Push — master ( 2b9e35...7f03ad )
by Maximo
02:03
created

library/Providers/SessionProvider.php (1 issue)

1
<?php
0 ignored issues
show
End of line character is invalid; expected "\n" but found "\r\n"
Loading history...
2
3
namespace Gewaer\Providers;
4
5
use function Gewaer\Core\envValue;
6
use Phalcon\Di\ServiceProviderInterface;
7
use Phalcon\DiInterface;
8
9
class SessionProvider implements ServiceProviderInterface
10
{
11
    /**
12
     * @param DiInterface $container
13
     */
14
    public function register(DiInterface $container)
15
    {
16
        $container->setShared(
17
            'session',
18
            function () {
19
                $backOptions = [
20
                    'servers' => [
21
                        0 => [
22
                            'host' => envValue('DATA_API_MEMCACHED_HOST', '127.0.0.1'),
23
                            'port' => envValue('DATA_API_MEMCACHED_PORT', 11211),
24
                            'weight' => envValue('DATA_API_MEMCACHED_WEIGHT', 100),
25
                        ],
26
                    ],
27
                    'client' => [
28
                        \Memcached::OPT_HASH => \Memcached::HASH_MD5,
29
                        \Memcached::OPT_PREFIX_KEY => 'bakasession-',
30
                    ],
31
                    'lifetime' => 8600,
32
                    'prefix' => $prefix . '-',
33
                    'persistent' => false
34
                ];
35
36
                $memcache = new \Phalcon\Session\Adapter\Libmemcached($backOptions);
37
38
                $memcache->start();
39
40
                return $memcache;
41
            }
42
        );
43
    }
44
}
45