Skip to content

Commit c436e33

Browse files
committed
renamed cache methods
1 parent bb602d3 commit c436e33

File tree

10 files changed

+39
-39
lines changed

10 files changed

+39
-39
lines changed

src/SplitIO/Component/Cache/Pool.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public function __construct(array $options = array())
3636
*
3737
* @return string
3838
*/
39-
public function getItem($key)
39+
public function get($key)
4040
{
4141
$this->assertValidKey($key);
4242
Di::getLogger()->debug("Fetching item ** $key ** from cache");
43-
return $this->adapter->getItem($key);
43+
return $this->adapter->get($key);
4444
}
4545

4646
/**
@@ -59,9 +59,9 @@ public function getItem($key)
5959
* key is not found. However, if no keys are specified then an empty
6060
* traversable MUST be returned instead.
6161
*/
62-
public function getItems(array $keys = array())
62+
public function fetchMany(array $keys = array())
6363
{
64-
return $this->adapter->getItems($keys);
64+
return $this->adapter->fetchMany($keys);
6565
}
6666

6767
public function isItemOnList($key, $value)

src/SplitIO/Component/Cache/SegmentCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function isInSegment($segmentName, $key)
3636
*/
3737
public function getChangeNumber($segmentName)
3838
{
39-
$since = Di::getCache()->getItem(self::getCacheKeyForSinceParameter($segmentName));
39+
$since = Di::getCache()->get(self::getCacheKeyForSinceParameter($segmentName));
4040
// empty check for nullable value
4141
return (empty($since)) ? -1 : $since;
4242
}

src/SplitIO/Component/Cache/SplitCache.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private static function getSplitNameFromCacheKey($key)
3737
*/
3838
public function getChangeNumber()
3939
{
40-
$since = Di::getCache()->getItem(self::getCacheKeyForSinceParameter());
40+
$since = Di::getCache()->get(self::getCacheKeyForSinceParameter());
4141
// empty check for nullable value
4242
return (empty($since)) ? -1 : $since;
4343
}
@@ -49,7 +49,7 @@ public function getChangeNumber()
4949
public function getSplit($splitName)
5050
{
5151
$cache = Di::getCache();
52-
$cacheItem = $cache->getItem(self::getCacheKeyForSplit($splitName));
52+
$cacheItem = $cache->get(self::getCacheKeyForSplit($splitName));
5353
return $cacheItem;
5454
}
5555

@@ -60,7 +60,7 @@ public function getSplit($splitName)
6060
public function getSplits($splitNames)
6161
{
6262
$cache = Di::getCache();
63-
$cacheItems = $cache->getItems(array_map('self::getCacheKeyForSplit', $splitNames));
63+
$cacheItems = $cache->fetchMany(array_map('self::getCacheKeyForSplit', $splitNames));
6464
$toReturn = array();
6565
foreach ($cacheItems as $key => $value) {
6666
$toReturn[self::getSplitNameFromCacheKey($key)] = $value;
@@ -100,7 +100,7 @@ public function trafficTypeExists($trafficType)
100100
{
101101
$cache = Di::getCache();
102102

103-
$count = $cache->getItem(self::getCacheKeyForTrafficType($trafficType));
103+
$count = $cache->get(self::getCacheKeyForTrafficType($trafficType));
104104
// empty check for nullable value
105105
return (empty($count) || $count < 1) ? false : true;
106106
}

src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public function getKeys($pattern = '*');
1616
* @param string $key
1717
* @return string
1818
*/
19-
public function getItem($key);
19+
public function get($key);
2020

21-
public function getItems(array $keys);
21+
public function fetchMany(array $keys);
2222

2323
/**
2424
* @param $key

src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ private function getRedisConfiguration($options)
207207
* @param string $key
208208
* @return string
209209
*/
210-
public function getItem($key)
210+
public function get($key)
211211
{
212212
return $this->client->get($key);
213213
}
@@ -225,7 +225,7 @@ public function getItem($key)
225225
*
226226
* @return array
227227
*/
228-
public function getItems(array $keys = array())
228+
public function fetchMany(array $keys = array())
229229
{
230230
$toReturn = array();
231231
if (count($keys) == 0) {

src/SplitIO/Component/Cache/Storage/Adapter/SafeRedisWrapper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ public function __construct(PRedis $cacheAdapter)
2727
* @param string $key
2828
* @return string
2929
*/
30-
public function getItem($key)
30+
public function get($key)
3131
{
3232
try {
33-
return $this->cacheAdapter->getItem($key);
33+
return $this->cacheAdapter->get($key);
3434
} catch (\Exception $e) {
3535
Di::getLogger()->critical("An error occurred getting " . $key . " from redis.");
3636
Di::getLogger()->critical($e->getMessage());
@@ -48,10 +48,10 @@ public function getItem($key)
4848
*
4949
* @return array
5050
*/
51-
public function getItems(array $keys = array())
51+
public function fetchMany(array $keys = array())
5252
{
5353
try {
54-
return $this->cacheAdapter->getItems($keys);
54+
return $this->cacheAdapter->fetchMany($keys);
5555
} catch (\Exception $e) {
5656
Di::getLogger()->critical("An error occurred getting " . json_encode($keys) . " from redis.");
5757
Di::getLogger()->critical($e->getMessage());

tests/Suite/Adapter/RedisAdapterTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testRedisWithOnlyParameters()
4949
]);
5050
$predisClient->set('this_is_a_test_key', 'this-is-a-test-value');
5151

52-
$value = $predis->getItem('this_is_a_test_key');
52+
$value = $predis->get('this_is_a_test_key');
5353
$this->assertEquals('this-is-a-test-value', $value);
5454

5555
$predisClient->del('this_is_a_test_key');
@@ -75,7 +75,7 @@ public function testRedisWithParametersAndPrefix()
7575
]);
7676
$predisClient->set('test-redis-assertion.this_is_a_test_key', 'this-is-a-test-value');
7777

78-
$value = $predis->getItem('this_is_a_test_key');
78+
$value = $predis->get('this_is_a_test_key');
7979
$this->assertEquals('this-is-a-test-value', $value);
8080

8181
$predisClient->del('test-redis-assertion.this_is_a_test_key');
@@ -102,7 +102,7 @@ public function testRedisWithParametersPrefixAndSentinels()
102102
]);
103103
$predisClient->set('test-redis-assertion.this_is_a_test_key', 'this-is-a-test-value');
104104

105-
$value = $predis->getItem('this_is_a_test_key');
105+
$value = $predis->get('this_is_a_test_key');
106106
$this->assertEquals('this-is-a-test-value', $value);
107107

108108
$predisClient->del('test-redis-assertion.this_is_a_test_key');
@@ -232,7 +232,7 @@ public function testRedisWithSentinels()
232232
)
233233
));
234234

235-
$predis->getItem('this_is_a_test_key');
235+
$predis->get('this_is_a_test_key');
236236
}
237237

238238
public function testRedisWithSentinelsAndDistributedStrategy()
@@ -248,7 +248,7 @@ public function testRedisWithSentinelsAndDistributedStrategy()
248248
)
249249
));
250250

251-
$predis->getItem('this_is_a_test_key');
251+
$predis->get('this_is_a_test_key');
252252
}
253253

254254
public function testRedisWithEmptyClusters()
@@ -322,7 +322,7 @@ public function testRedisWithInvalidKeyHashtagInClusters()
322322
)
323323
));
324324

325-
$predis->getItem('this_is_a_test_key');
325+
$predis->get('this_is_a_test_key');
326326
}
327327

328328
public function testRedisWithInvalidBeginingKeyHashtagInClusters()
@@ -342,7 +342,7 @@ public function testRedisWithInvalidBeginingKeyHashtagInClusters()
342342
)
343343
));
344344

345-
$predis->getItem('this_is_a_test_key');
345+
$predis->get('this_is_a_test_key');
346346
}
347347

348348
public function testRedisWithWrongTypeKeyHashtagInClusters()
@@ -362,7 +362,7 @@ public function testRedisWithWrongTypeKeyHashtagInClusters()
362362
)
363363
));
364364

365-
$predis->getItem('this_is_a_test_key');
365+
$predis->get('this_is_a_test_key');
366366
}
367367

368368
public function testRedisWithWrongLengthKeyHashtagInClusters()
@@ -382,7 +382,7 @@ public function testRedisWithWrongLengthKeyHashtagInClusters()
382382
)
383383
));
384384

385-
$predis->getItem('this_is_a_test_key');
385+
$predis->get('this_is_a_test_key');
386386
}
387387

388388
public function testRedisWithClusters()
@@ -398,7 +398,7 @@ public function testRedisWithClusters()
398398
)
399399
));
400400

401-
$predis->getItem('this_is_a_test_key');
401+
$predis->get('this_is_a_test_key');
402402
}
403403

404404
public function testRedisWithoutCustomKeyHashtagClusters()
@@ -413,7 +413,7 @@ public function testRedisWithoutCustomKeyHashtagClusters()
413413
)
414414
));
415415

416-
$predis->getItem('this_is_a_test_key');
416+
$predis->get('this_is_a_test_key');
417417
}
418418

419419
public function testRedisWithClustersKeyHashTags()
@@ -432,7 +432,7 @@ public function testRedisWithClustersKeyHashTags()
432432
)
433433
));
434434

435-
$predis->getItem('this_is_a_test_key');
435+
$predis->get('this_is_a_test_key');
436436
}
437437

438438
public function testRedisWithClustersKeyHashTagsInvalid()
@@ -451,7 +451,7 @@ public function testRedisWithClustersKeyHashTagsInvalid()
451451
)
452452
));
453453

454-
$predis->getItem('this_is_a_test_key');
454+
$predis->get('this_is_a_test_key');
455455
}
456456

457457
public function testRedisWithClustersKeyHashTagsInvalidHashTags()
@@ -470,7 +470,7 @@ public function testRedisWithClustersKeyHashTagsInvalidHashTags()
470470
)
471471
));
472472

473-
$predis->getItem('this_is_a_test_key');
473+
$predis->get('this_is_a_test_key');
474474
}
475475

476476
public function testRedisWithClustersKeyHashTagsValid()
@@ -486,7 +486,7 @@ public function testRedisWithClustersKeyHashTagsValid()
486486
)
487487
));
488488

489-
$predis->getItem('this_is_a_test_key');
489+
$predis->get('this_is_a_test_key');
490490
}
491491

492492
public function testRedisSSLWithClusterFails()

tests/Suite/Redis/PRedisReadOnlyMock.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public function __construct(PRedis $predis)
1818
* @param string $key
1919
* @return string
2020
*/
21-
public function getItem($key)
21+
public function get($key)
2222
{
23-
return $this->predis->getItem($key);
23+
return $this->predis->get($key);
2424
}
2525

2626
/**
@@ -39,9 +39,9 @@ public function getItem($key)
3939
* key is not found. However, if no keys are specified then an empty
4040
* traversable MUST be returned instead.
4141
*/
42-
public function getItems(array $keys = array())
42+
public function fetchMany(array $keys = array())
4343
{
44-
return $this->predis->getItems($keys);
44+
return $this->predis->fetchMany($keys);
4545
}
4646

4747
/**

tests/Suite/Redis/SafeRedisWrapperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public function testAllMethodsException()
4040
$refProperty->setValue($predisAdapter, $predisMock);
4141
$safeRedisWrapper = new SafeRedisWrapper($predisAdapter);
4242

43-
$this->assertEquals(false, $safeRedisWrapper->getItem("some"));
44-
$this->assertEquals(array(), $safeRedisWrapper->getItems(array("some")));
43+
$this->assertEquals(false, $safeRedisWrapper->get("some"));
44+
$this->assertEquals(array(), $safeRedisWrapper->fetchMany(array("some")));
4545
$this->assertEquals(false, $safeRedisWrapper->isOnList("some", "another"));
4646
$this->assertEquals(array(), $safeRedisWrapper->getKeys("some"));
4747
$this->assertEquals(0, $safeRedisWrapper->rightPushQueue("some", "another"));

tests/Suite/Sdk/SdkClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ public function testCacheExceptionReturnsControl()
487487
$splitSdk = $splitFactory->client();
488488

489489
$cachePoolMethods = array(
490-
'getItem', 'getItems', 'isItemOnList', 'getKeys', 'rightPushInList', 'expireKey'
490+
'get', 'fetchMany', 'isItemOnList', 'getKeys', 'rightPushInList', 'expireKey'
491491
);
492492
$cachePool = $this
493493
->getMockBuilder('\SplitIO\Component\Cache\Pool')

0 commit comments

Comments
 (0)