Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
redisconnection.php
1<?php
2
3namespace Bitrix\Main\Data;
4
12{
14 protected $configurator;
15
16 public function __construct(array $configuration)
17 {
18 parent::__construct($configuration);
19
20 $this->configurator = new Configurator\RedisConnectionConfigurator($this->getConfiguration());
21 }
22
23 protected function connectInternal()
24 {
25 $this->resource = $this->configurator->createConnection();
26 $this->isConnected = (bool)$this->resource;
27 }
28
29 protected function disconnectInternal()
30 {
31 if ($this->isConnected())
32 {
33 $this->resource->close();
34 $this->resource = null;
35 $this->isConnected = false;
36 }
37 }
38
39 public function get($key)
40 {
41 if (!$this->isConnected())
42 {
43 $this->connect();
44 }
45
46 return $this->resource->get($key);
47 }
48
49 public function set($key, $value)
50 {
51 if (!$this->isConnected())
52 {
53 $this->connect();
54 }
55
56 return $this->resource->set($key, $value);
57 }
58}
__construct(array $configuration)