Skip to content

Commit bb602d3

Browse files
committed
remove Item
1 parent f85782e commit bb602d3

File tree

10 files changed

+18
-208
lines changed

10 files changed

+18
-208
lines changed

src/SplitIO/Component/Cache/Item.php

Lines changed: 0 additions & 174 deletions
This file was deleted.

src/SplitIO/Component/Cache/Pool.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public function __construct(array $options = array())
3434
* If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
3535
* MUST be thrown.
3636
*
37-
* @return \SplitIO\Component\Cache\Item
38-
* The corresponding Cache Item.
37+
* @return string
3938
*/
4039
public function getItem($key)
4140
{

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))->get();
39+
$since = Di::getCache()->getItem(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())->get();
40+
$since = Di::getCache()->getItem(self::getCacheKeyForSinceParameter());
4141
// empty check for nullable value
4242
return (empty($since)) ? -1 : $since;
4343
}
@@ -50,7 +50,7 @@ public function getSplit($splitName)
5050
{
5151
$cache = Di::getCache();
5252
$cacheItem = $cache->getItem(self::getCacheKeyForSplit($splitName));
53-
return $cacheItem->get();
53+
return $cacheItem;
5454
}
5555

5656
/**
@@ -63,7 +63,7 @@ public function getSplits($splitNames)
6363
$cacheItems = $cache->getItems(array_map('self::getCacheKeyForSplit', $splitNames));
6464
$toReturn = array();
6565
foreach ($cacheItems as $key => $value) {
66-
$toReturn[self::getSplitNameFromCacheKey($key)] = $value->get();
66+
$toReturn[self::getSplitNameFromCacheKey($key)] = $value;
6767
}
6868
return $toReturn;
6969
}
@@ -100,7 +100,7 @@ public function trafficTypeExists($trafficType)
100100
{
101101
$cache = Di::getCache();
102102

103-
$count = $cache->getItem(self::getCacheKeyForTrafficType($trafficType))->get();
103+
$count = $cache->getItem(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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function getKeys($pattern = '*');
1414

1515
/**
1616
* @param string $key
17-
* @return \SplitIO\Component\Cache\Item
17+
* @return string
1818
*/
1919
public function getItem($key);
2020

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

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,11 @@ private function getRedisConfiguration($options)
205205

206206
/**
207207
* @param string $key
208-
* @return \SplitIO\Component\Cache\Item
208+
* @return string
209209
*/
210210
public function getItem($key)
211211
{
212-
$item = new Item($key);
213-
214-
$redisItem = $this->client->get($key);
215-
216-
if ($redisItem !== null) {
217-
$item->set($redisItem);
218-
}
219-
220-
return $item;
212+
return $this->client->get($key);
221213
}
222214

223215

@@ -231,11 +223,7 @@ public function getItem($key)
231223
* If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException
232224
* MUST be thrown.
233225
*
234-
* @return array|\Traversable
235-
* A traversable collection of Cache Items keyed by the cache keys of
236-
* each item. A Cache item will be returned for each key, even if that
237-
* key is not found. However, if no keys are specified then an empty
238-
* traversable MUST be returned instead.
226+
* @return array
239227
*/
240228
public function getItems(array $keys = array())
241229
{
@@ -245,10 +233,7 @@ public function getItems(array $keys = array())
245233
}
246234
$values = $this->client->mget($keys);
247235
foreach ($keys as $index => $key) {
248-
$toReturn[$key] = new Item($key);
249-
if (!is_null($values[$index])) {
250-
$toReturn[$key]->set($values[$index]);
251-
}
236+
$toReturn[$key] = $values[$index];
252237
}
253238
return $toReturn;
254239
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(PRedis $cacheAdapter)
2525

2626
/**
2727
* @param string $key
28-
* @return \SplitIO\Component\Cache\Item
28+
* @return string
2929
*/
3030
public function getItem($key)
3131
{
@@ -35,7 +35,7 @@ public function getItem($key)
3535
Di::getLogger()->critical("An error occurred getting " . $key . " from redis.");
3636
Di::getLogger()->critical($e->getMessage());
3737
Di::getLogger()->critical($e->getTraceAsString());
38-
return new Item($key);
38+
return null;
3939
}
4040
}
4141

tests/Suite/Adapter/RedisAdapterTest.php

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

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

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

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

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

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

108108
$predisClient->del('test-redis-assertion.this_is_a_test_key');
109109
}

tests/Suite/Redis/PRedisReadOnlyMock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct(PRedis $predis)
1616

1717
/**
1818
* @param string $key
19-
* @return \SplitIO\Component\Cache\Item
19+
* @return string
2020
*/
2121
public function getItem($key)
2222
{

tests/Suite/Redis/SafeRedisWrapperTest.php

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

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

0 commit comments

Comments
 (0)