@@ 30-82 (lines=53) @@ | ||
27 | * THE SOFTWARE. |
|
28 | */ |
|
29 | ||
30 | class PhpRedis extends AbstractEnhancedProvider { |
|
31 | ||
32 | public function __construct( |
|
33 | $server = '127.0.0.1', |
|
34 | $port = 6379, |
|
35 | $timeout = 0, |
|
36 | LoggerInterface $logger = null |
|
37 | ) { |
|
38 | ||
39 | if ( empty($server) ) { |
|
40 | throw new InvalidCacheArgumentException("Invalid or unspecified memcached server"); |
|
41 | } |
|
42 | ||
43 | $port = DataFilter::filterPort($port, 6379); |
|
44 | $timeout = DataFilter::filterInteger($timeout, 0, PHP_INT_MAX, 0); |
|
45 | ||
46 | try { |
|
47 | ||
48 | $this->driver = new PhpRedisDriver([ |
|
49 | 'server' => $server, |
|
50 | 'port' => $port, |
|
51 | 'timeout' => $timeout |
|
52 | ]); |
|
53 | ||
54 | parent::__construct($logger); |
|
55 | ||
56 | } catch (Exception $e) { |
|
57 | ||
58 | throw new CacheException($e->getMessage()); |
|
59 | ||
60 | } |
|
61 | ||
62 | } |
|
63 | ||
64 | public function getInstance() { |
|
65 | return $this->driver->getInstance(); |
|
66 | } |
|
67 | ||
68 | public function getStats() { |
|
69 | ||
70 | $info = $this->driver->stats(); |
|
71 | ||
72 | return new EnhancedCacheItemPoolStats( |
|
73 | $this->getId(), |
|
74 | $this->driver->getName(), |
|
75 | $this->getState(), |
|
76 | $info['objects'], |
|
77 | $info['stats'] |
|
78 | ); |
|
79 | ||
80 | } |
|
81 | ||
82 | } |
|
83 |
@@ 30-82 (lines=53) @@ | ||
27 | * THE SOFTWARE. |
|
28 | */ |
|
29 | ||
30 | class PhpRedis extends AbstractEnhancedProvider { |
|
31 | ||
32 | public function __construct( |
|
33 | $server = '127.0.0.1', |
|
34 | $port = 6379, |
|
35 | $timeout = 0, |
|
36 | LoggerInterface $logger = null |
|
37 | ) { |
|
38 | ||
39 | if ( empty($server) ) { |
|
40 | throw new InvalidSimpleCacheArgumentException("Invalid or unspecified memcached server"); |
|
41 | } |
|
42 | ||
43 | $port = DataFilter::filterPort($port, 6379); |
|
44 | $timeout = DataFilter::filterInteger($timeout, 0, PHP_INT_MAX, 0); |
|
45 | ||
46 | try { |
|
47 | ||
48 | $this->driver = new PhpRedisDriver([ |
|
49 | 'server' => $server, |
|
50 | 'port' => $port, |
|
51 | 'timeout' => $timeout |
|
52 | ]); |
|
53 | ||
54 | parent::__construct($logger); |
|
55 | ||
56 | } catch (Exception $e) { |
|
57 | ||
58 | throw new SimpleCacheException($e->getMessage()); |
|
59 | ||
60 | } |
|
61 | ||
62 | } |
|
63 | ||
64 | public function getInstance() { |
|
65 | return $this->driver->getInstance(); |
|
66 | } |
|
67 | ||
68 | public function getStats() { |
|
69 | ||
70 | $info = $this->driver->stats(); |
|
71 | ||
72 | return new EnhancedCacheItemPoolStats( |
|
73 | $this->getId(), |
|
74 | $this->driver->getName(), |
|
75 | $this->getState(), |
|
76 | $info['objects'], |
|
77 | $info['stats'] |
|
78 | ); |
|
79 | ||
80 | } |
|
81 | ||
82 | } |
|
83 |