-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMemcachedHandler.php
More file actions
39 lines (33 loc) · 1016 Bytes
/
Copy pathMemcachedHandler.php
File metadata and controls
39 lines (33 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Bolt\Session\Handler;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler;
/**
* {@inheritdoc}
*
* Added lazy write support.
*
* @author Carson Full <carsonfull@gmail.com>
*/
class MemcachedHandler extends MemcachedSessionHandler implements LazyWriteHandlerInterface
{
/** @var int Time to live in seconds */
protected $ttl;
/** @var string Key prefix for shared environments */
protected $prefix;
/**
* {@inheritdoc}
*/
public function __construct(\Memcached $memcached, array $options = [])
{
parent::__construct($memcached, $options);
$this->ttl = isset($options['expiretime']) ? (int) $options['expiretime'] : 86400;
$this->prefix = isset($options['prefix']) ? $options['prefix'] : 'sf2s';
}
/**
* {@inheritdoc}
*/
public function updateTimestamp($sessionId, $data)
{
$this->getMemcached()->touch($this->prefix . $sessionId, time() + $this->ttl);
}
}