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