Skip to content

Commit 5f28bee

Browse files
authored
Merge pull request #8 from Traackr/BI-8371-redis-version-regression
BI-8371: Allow Credis profile version to be passed in.
2 parents 61f2bad + c1a3ffc commit 5f28bee

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
language: php
22

33
php:
4-
- 5.3
5-
- 5.4
6-
- 5.5
74
- 5.6
8-
5+
- 7.0
6+
- 7.1
97
before_script:
108
- wget http://getcomposer.org/composer.phar
119
- php composer.phar install --dev

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ CakePHP:
4040
'engine' => 'Fallback',
4141
'name' => "post_data",
4242
'primary' => array(
43+
'profile' => '2.8', // optional, if you want to hardcode a predis profile to use
4344
'engine' => 'RedisTree',
4445
'server' => 'redis-server',
4546
'port' => 6379,

src/RedisTreeEngine.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class RedisTreeEngine extends CacheEngine
1515
* Redis wrapper.
1616
*/
1717
protected $redis = null;
18-
18+
1919
/**
2020
* Needs to be protected, not private since it's reset in RedisTreeMockEngine
2121
*/
@@ -56,11 +56,19 @@ public function init($settings = array())
5656

5757
if (!isset($this->redis)) {
5858
try {
59-
$this->redis = new Predis\Client(array(
60-
'scheme' => 'tcp',
61-
'host' => $this->settings['server'],
62-
'port' => $this->settings['port'],
63-
));
59+
if (isset($settings['profile'])) {
60+
$this->redis = new Predis\Client(array(
61+
'scheme' => 'tcp',
62+
'host' => $this->settings['server'],
63+
'port' => $this->settings['port'],
64+
), array('profile' => $settings['profile']));
65+
} else {
66+
$this->redis = new Predis\Client(array(
67+
'scheme' => 'tcp',
68+
'host' => $this->settings['server'],
69+
'port' => $this->settings['port'],
70+
));
71+
}
6472
} catch (Exception $e) {
6573
// If creation fails, return false
6674
return false;
@@ -308,12 +316,12 @@ public function delete($key)
308316
private function _mdelete($keys)
309317
{
310318
$finalKeys = array();
311-
319+
312320
foreach ($keys as $key) {
313321
// keys() is an expensive call; only call it if we need to (i.e. if there actually is a wildcard);
314322
// the chars "?*[" seem to be the right ones to listen for according to: http://redis.io/commands/KEYS
315323
if (preg_match('/[\?\*\[]/', $key)) {
316-
324+
317325
if ($this->supportsScan) {
318326
$currKeys = array();
319327
foreach (new Iterator\Keyspace($this->redis, $key) as $currKey) {
@@ -337,7 +345,7 @@ private function _mdelete($keys)
337345
return 0;
338346
}
339347
}
340-
348+
341349
/**
342350
* Internal single-val delete.
343351
* @param $key
@@ -383,7 +391,7 @@ public function clear($check = false)
383391
if ($check) {
384392
return true;
385393
}
386-
394+
387395
if ($this->supportsScan) {
388396
$keys = array();
389397
foreach (new Iterator\Keyspace($this->redis, $this->settings['prefix'] . '*') as $currKey) {

0 commit comments

Comments
 (0)