-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathredis.module
125 lines (117 loc) · 5.2 KB
/
redis.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
* @file
* Redis module.
*
* This file is a placeholder for other modules that need the Redis client for
* something else than lock and cache.
*/
// Include our own autoloader to ensure classes to be there.
// We cannot rely on core in case of early bootstrap phases.
require_once dirname(__FILE__) . '/redis.autoload.inc';
/**
* Implements hook_menu().
*/
function redis_menu() {
$items = array();
$items['admin/config/development/performance/cache'] = array(
'title' => "Cache",
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/config/development/performance/redis'] = array(
'title' => "Redis",
'page callback' => 'backdrop_get_form',
'page arguments' => array('redis_settings_form'),
'access arguments' => array('administer site configuration'),
'type' => MENU_LOCAL_TASK,
'file' => 'redis.admin.inc',
);
return $items;
}
/**
* Implements hook_help().
*/
function redis_help($path, $arg) {
switch ($path) {
case 'admin/config/development/performance/redis':
$messages =
'<p>' . t("Redis module is optional if you are using only a cache or lock backend. The full API will be automatically loaded and its configuration will live into the <em>settings.php</em> file. If you access to this screen, it's probably because another contrib module needs it as a dependency for using the Redis client. If you didn't enabled such module, you are strongly advised to disable the Redis module on the module page.") . '</p>' .
'<p>' . t("While Redis client configuration can be changed through the web, if you are using a cache or lock backend they must be set in the <em>settings.php</em> file. Once this done, any modification done using this form will be ignored, and real settings in use will be get at early bootstrap phase, before the configuration system is bootstrapped.") . '</p>';
if (Redis_Client::getClient()) {
$messages .= '<p><strong>' . t("Current connected client uses the <em>@name</em> library.", array('@name' => Redis_Client::getClientInterfaceName())) . '</strong></p>';
}
return $messages;
}
}
/**
* Implements hook_config_info().
*/
function redis_config_info() {
$prefixes['redis.settings'] = array(
'label' => t('Redis module settings'),
'group' => t('Configuration'),
);
return $prefixes;
}
/**
* Get Redis client for php-redis extension.
*
* @return \Redis
*/
function phpredis_client_get() {
if ('PhpRedis' !== config_get('redis.settings', 'redis_client_interface')) {
throw new LogicException("Redis is not configured to use the php-redis client");
}
return Redis_Client::getClient();
}
/**
* Get Redis client for Predis library.
*
* @return \Predis\Client
*/
function predis_client_get() {
if ('Predis' !== config_get('redis.settings', 'redis_client_interface')) {
throw new LogicException("Redis is not configured to use the Predis client");
}
return Redis_Client::getClient();
}
/**
* Implements hook_autoload_info().
*/
function redis_autoload_info() {
return array(
'Redis_AbstractBackend' => 'lib/Redis/AbstractBackend.php',
'Redis_BackendInterface' => 'lib/Redis/BackendInterface.php',
'Redis_Cache_BackendInterface' => 'lib/Redis/Cache/BackendInterface.php',
'Redis_Cache_Base' => 'lib/Redis/Cache/Base.php',
'Redis_Cache_PhpRedis' => 'lib/Redis/Cache/PhpRedis.php',
'Redis_Cache_Predis' => 'lib/Redis/Cache/Predis.php',
'Redis_Cache' => 'lib/Redis/Cache.php',
'Redis_CacheCompressed' => 'lib/Redis/CacheCompressed.php',
'Redis_Client_FactoryInterface' => 'lib/Redis/Client/FactoryInterface.php',
'Redis_Client_Manager' => 'lib/Redis/Client/Manager.php',
'Redis_Client_PhpRedis' => 'lib/Redis/Client/PhpRedis.php',
'Redis_Client_Predis' => 'lib/Redis/Client/Predis.php',
'Redis_Client' => 'lib/Redis/Client.php',
'Redis_Lock_BackendInterface' => 'lib/Redis/Lock/BackendInterface.php',
'Redis_Lock_DefaultBackend' => 'lib/Redis/Lock/DefaultBackend.php',
'Redis_Lock_PhpRedis' => 'lib/Redis/Lock/PhpRedis.php',
'Redis_Lock_Predis' => 'lib/Redis/Lock/Predis.php',
'Redis_Lock' => 'lib/Redis/Lock.php',
'Redis_Path_AbstractHashLookup' => 'lib/Redis/Path/AbstractHashLookup.php',
'Redis_Path_HashLookupInterface' => 'lib/Redis/Path/HashLookupInterface.php',
'Redis_Path_NullHashLookup' => 'lib/Redis/Path/NullHashLookup.php',
'Redis_Path_PhpRedis' => 'lib/Redis/Path/PhpRedis.php',
'Redis_Path_Predis' => 'lib/Redis/Path/Predis.php',
'Redis_Queue_Base' => 'lib/Redis/Queue/Base.php',
'Redis_Queue_PhpRedis' => 'lib/Redis/Queue/PhpRedis.php',
'Redis_Queue' => 'lib/Redis/Queue.php',
'Redis_Tests_AbstractUnitTestCase' => 'lib/Redis/Tests/AbstractUnitTestCase.php',
'Redis_Tests_Cache_FixesUnitTestCase' => 'lib/Redis/Tests/Cache/FixesUnitTestCase.php',
'Redis_Tests_Cache_FlushUnitTestCase' => 'lib/Redis/Tests/Cache/FlushUnitTestCase.php',
'Redis_Tests_Client_MockFactory' => 'lib/Redis/Tests/Client/MockFactory.php',
'Redis_Tests_Lock_LockingUnitTestCase' => 'lib/Redis/Tests/Lock/LockingUnitTestCase.php',
'Redis_Tests_Path_PathUnitTestCase' => 'lib/Redis/Tests/Path/PathUnitTestCase.php',
'Redis_Tests_Queue_QueueUnitTestCase' => 'lib/Redis/Tests/Queue/QueueUnitTestCase.php',
);
}