Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
cacheengineredis.php
1
<?php
2
namespace
Bitrix\Main\Data
;
3
4
class
CacheEngineRedis
extends
CacheEngine
5
{
6
public
function
getConnectionName
() : string
7
{
8
return
'cache.redis'
;
9
}
10
11
public
static
function
getConnectionClass
()
12
{
13
return
RedisConnection::class;
14
}
15
16
public
function
set
($key, $ttl, $value) : bool
17
{
18
$ttl = (int) $ttl;
19
if
($ttl > 0)
20
{
21
return
self::$engine->setex($key, $ttl, $value);
22
}
23
else
24
{
25
return
self::$engine->set($key, $value);
26
}
27
}
28
29
public
function
get
($key)
30
{
31
return
self::$engine->get($key);
32
}
33
34
public
function
del
($key)
35
{
36
self::$engine->del($key);
37
}
38
39
public
function
setNotExists
($key, $ttl, $value)
40
{
41
$ttl = (int) $ttl;
42
if
(self::$engine->setnx($key, $value))
43
{
44
if
($ttl > 0)
45
{
46
self::$engine->expire($key, $ttl);
47
}
48
49
return
true
;
50
}
51
52
return
false
;
53
}
54
55
public
function
addToSet
($key, $value)
56
{
57
self::$engine->sAdd($key, $value);
58
}
59
60
public
function
getSet
($key) : array
61
{
62
$list = self::$engine->sMembers($key);
63
if
(!is_array($list))
64
{
65
$list = [];
66
}
67
return
$list;
68
}
69
70
public
function
deleteBySet
($key, $prefix =
''
)
71
{
72
$list = self::$engine->sMembers($key);
73
74
if
(is_array($list) && !empty($list))
75
{
76
if
($prefix ==
''
)
77
{
78
self::$engine->del($list);
79
}
80
else
81
{
82
foreach
($list as $key)
83
{
84
self::$engine->del($prefix . $key);
85
}
86
}
87
}
88
}
89
90
public
function
delFromSet
($key, $member)
91
{
92
if
(is_array($member))
93
{
94
foreach
($member as $keyID)
95
{
96
self::$engine->sRem($key, $keyID);
97
}
98
}
99
else
100
{
101
self::$engine->sRem($key, $member);
102
}
103
}
104
}
Bitrix\Main\Data\CacheEngine
Definition
cacheengine.php:9
Bitrix\Main\Data\CacheEngineRedis
Definition
cacheengineredis.php:5
Bitrix\Main\Data\CacheEngineRedis\getSet
getSet($key)
Definition
cacheengineredis.php:60
Bitrix\Main\Data\CacheEngineRedis\getConnectionName
getConnectionName()
Definition
cacheengineredis.php:6
Bitrix\Main\Data\CacheEngineRedis\del
del($key)
Definition
cacheengineredis.php:34
Bitrix\Main\Data\CacheEngineRedis\deleteBySet
deleteBySet($key, $prefix='')
Definition
cacheengineredis.php:70
Bitrix\Main\Data\CacheEngineRedis\getConnectionClass
static getConnectionClass()
Definition
cacheengineredis.php:11
Bitrix\Main\Data\CacheEngineRedis\setNotExists
setNotExists($key, $ttl, $value)
Definition
cacheengineredis.php:39
Bitrix\Main\Data\CacheEngineRedis\delFromSet
delFromSet($key, $member)
Definition
cacheengineredis.php:90
Bitrix\Main\Data\CacheEngineRedis\addToSet
addToSet($key, $value)
Definition
cacheengineredis.php:55
Bitrix\Main\Data
Definition
aliases.php:105
modules
main
lib
data
cacheengineredis.php
Создано системой
1.10.0