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