From bb602d3ea873c58d2a73329e9ca47c351477c45e Mon Sep 17 00:00:00 2001 From: Matias Melograno Date: Mon, 21 Mar 2022 13:00:03 -0300 Subject: [PATCH 1/2] remove Item --- src/SplitIO/Component/Cache/Item.php | 174 ------------------ src/SplitIO/Component/Cache/Pool.php | 3 +- src/SplitIO/Component/Cache/SegmentCache.php | 2 +- src/SplitIO/Component/Cache/SplitCache.php | 8 +- .../Adapter/CacheStorageAdapterInterface.php | 2 +- .../Cache/Storage/Adapter/PRedis.php | 23 +-- .../Storage/Adapter/SafeRedisWrapper.php | 4 +- tests/Suite/Adapter/RedisAdapterTest.php | 6 +- tests/Suite/Redis/PRedisReadOnlyMock.php | 2 +- tests/Suite/Redis/SafeRedisWrapperTest.php | 2 +- 10 files changed, 18 insertions(+), 208 deletions(-) delete mode 100644 src/SplitIO/Component/Cache/Item.php diff --git a/src/SplitIO/Component/Cache/Item.php b/src/SplitIO/Component/Cache/Item.php deleted file mode 100644 index af84f3de..00000000 --- a/src/SplitIO/Component/Cache/Item.php +++ /dev/null @@ -1,174 +0,0 @@ -assertValidKey($key); - $this->key = $key; - } - - /** - * Returns the key for the current cache item. - * - * The key is loaded by the Implementing Library, but should be available to - * the higher level callers when needed. - * - * @return string - * The key string for this cache item. - */ - public function getKey() - { - return (string) $this->key; - } - - /** - * Retrieves the value of the item from the cache associated with this object's key. - * - * The value returned must be identical to the value originally stored by set(). - * - * If isHit() returns false, this method MUST return null. Note that null - * is a legitimate cached value, so the isHit() method SHOULD be used to - * differentiate between "null value was found" and "no value was found." - * - * @return mixed - * The value corresponding to this cache item's key, or null if not found. - */ - public function get() - { - if (!$this->isHit()) { - return null; - } - - if ($this->value !== null) { - return $this->value; - } - } - - /** - * Confirms if the cache item lookup resulted in a cache hit. - * - * Note: This method MUST NOT have a race condition between calling isHit() - * and calling get(). - * - * @return bool - * True if the request resulted in a cache hit. False otherwise. - */ - public function isHit() - { - return $this->hit; - } - - /** - * Sets the value represented by this cache item. - * - * The $value argument may be any item that can be serialized by PHP, - * although the method of serialization is left up to the Implementing - * Library. - * - * @param mixed $value - * The serializable value to be stored. - * - * @return static - * The invoked object. - */ - public function set($value) - { - $this->value = $value; - $this->hit = true; - return $this; - } - - /** - * Sets the expiration time for this cache item. - * - * @param \DateTimeInterface $expiration - * The point in time after which the item MUST be considered expired. - * If null is passed explicitly, a default value MAY be used. If none is set, - * the value should be stored permanently or for as long as the - * implementation allows. - * - * @return static - * The called object. - */ - public function expiresAt($expiration) - { - // DateTimeInterface has been added for PHP>=5.5, so, also accept DateTime - if ($expiration instanceof DateTimeInterface || $expiration instanceof DateTime) { - // getting unix timestamp - $this->expire = (int) $expiration->format('U'); - } else { - $this->expire = 0; - } - - return $this; - } - - /** - * Sets the expiration time for this cache item. - * - * @param int|\DateInterval $time - * The period of time from the present after which the item MUST be considered - * expired. An integer parameter is understood to be the time in seconds until - * expiration. If null is passed explicitly, a default value MAY be used. - * If none is set, the value should be stored permanently or for as long as the - * implementation allows. - * - * @return static - * The called object. - */ - public function expiresAfter($time) - { - if ($time instanceof DateInterval) { - $expire = new DateTime(); - $expire->add($time); - // convert datetime to unix timestamp - $this->expire = (int) $expire->format('U'); - } elseif (is_int($time)) { - $this->expire = time() + $time; - } elseif (is_null($time)) { - $this->expire = 0; - } - - Di::getLogger()->info("//--> [CacheItem:{$this->key}] Set expiration time at: - {$this->expire} - ".date('Y-m-d H:i:s', $this->expire)); - - return $this; - } - - /** - * Returns the set expiration time as integer. - * @return int - */ - public function getExpiration() - { - return $this->expire; - } -} diff --git a/src/SplitIO/Component/Cache/Pool.php b/src/SplitIO/Component/Cache/Pool.php index 7490dab1..cc72fb05 100644 --- a/src/SplitIO/Component/Cache/Pool.php +++ b/src/SplitIO/Component/Cache/Pool.php @@ -34,8 +34,7 @@ public function __construct(array $options = array()) * If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException * MUST be thrown. * - * @return \SplitIO\Component\Cache\Item - * The corresponding Cache Item. + * @return string */ public function getItem($key) { diff --git a/src/SplitIO/Component/Cache/SegmentCache.php b/src/SplitIO/Component/Cache/SegmentCache.php index bca19c5f..be3e3d33 100644 --- a/src/SplitIO/Component/Cache/SegmentCache.php +++ b/src/SplitIO/Component/Cache/SegmentCache.php @@ -36,7 +36,7 @@ public function isInSegment($segmentName, $key) */ public function getChangeNumber($segmentName) { - $since = Di::getCache()->getItem(self::getCacheKeyForSinceParameter($segmentName))->get(); + $since = Di::getCache()->getItem(self::getCacheKeyForSinceParameter($segmentName)); // empty check for nullable value return (empty($since)) ? -1 : $since; } diff --git a/src/SplitIO/Component/Cache/SplitCache.php b/src/SplitIO/Component/Cache/SplitCache.php index a77f8d28..cf6901f1 100644 --- a/src/SplitIO/Component/Cache/SplitCache.php +++ b/src/SplitIO/Component/Cache/SplitCache.php @@ -37,7 +37,7 @@ private static function getSplitNameFromCacheKey($key) */ public function getChangeNumber() { - $since = Di::getCache()->getItem(self::getCacheKeyForSinceParameter())->get(); + $since = Di::getCache()->getItem(self::getCacheKeyForSinceParameter()); // empty check for nullable value return (empty($since)) ? -1 : $since; } @@ -50,7 +50,7 @@ public function getSplit($splitName) { $cache = Di::getCache(); $cacheItem = $cache->getItem(self::getCacheKeyForSplit($splitName)); - return $cacheItem->get(); + return $cacheItem; } /** @@ -63,7 +63,7 @@ public function getSplits($splitNames) $cacheItems = $cache->getItems(array_map('self::getCacheKeyForSplit', $splitNames)); $toReturn = array(); foreach ($cacheItems as $key => $value) { - $toReturn[self::getSplitNameFromCacheKey($key)] = $value->get(); + $toReturn[self::getSplitNameFromCacheKey($key)] = $value; } return $toReturn; } @@ -100,7 +100,7 @@ public function trafficTypeExists($trafficType) { $cache = Di::getCache(); - $count = $cache->getItem(self::getCacheKeyForTrafficType($trafficType))->get(); + $count = $cache->getItem(self::getCacheKeyForTrafficType($trafficType)); // empty check for nullable value return (empty($count) || $count < 1) ? false : true; } diff --git a/src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php b/src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php index 6276c5fb..45aec490 100644 --- a/src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php +++ b/src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php @@ -14,7 +14,7 @@ public function getKeys($pattern = '*'); /** * @param string $key - * @return \SplitIO\Component\Cache\Item + * @return string */ public function getItem($key); diff --git a/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php b/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php index e0c65cd1..8fc7cdb9 100644 --- a/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php +++ b/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php @@ -205,19 +205,11 @@ private function getRedisConfiguration($options) /** * @param string $key - * @return \SplitIO\Component\Cache\Item + * @return string */ public function getItem($key) { - $item = new Item($key); - - $redisItem = $this->client->get($key); - - if ($redisItem !== null) { - $item->set($redisItem); - } - - return $item; + return $this->client->get($key); } @@ -231,11 +223,7 @@ public function getItem($key) * If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException * MUST be thrown. * - * @return array|\Traversable - * A traversable collection of Cache Items keyed by the cache keys of - * each item. A Cache item will be returned for each key, even if that - * key is not found. However, if no keys are specified then an empty - * traversable MUST be returned instead. + * @return array */ public function getItems(array $keys = array()) { @@ -245,10 +233,7 @@ public function getItems(array $keys = array()) } $values = $this->client->mget($keys); foreach ($keys as $index => $key) { - $toReturn[$key] = new Item($key); - if (!is_null($values[$index])) { - $toReturn[$key]->set($values[$index]); - } + $toReturn[$key] = $values[$index]; } return $toReturn; } diff --git a/src/SplitIO/Component/Cache/Storage/Adapter/SafeRedisWrapper.php b/src/SplitIO/Component/Cache/Storage/Adapter/SafeRedisWrapper.php index 5c46b79c..e4b12665 100644 --- a/src/SplitIO/Component/Cache/Storage/Adapter/SafeRedisWrapper.php +++ b/src/SplitIO/Component/Cache/Storage/Adapter/SafeRedisWrapper.php @@ -25,7 +25,7 @@ public function __construct(PRedis $cacheAdapter) /** * @param string $key - * @return \SplitIO\Component\Cache\Item + * @return string */ public function getItem($key) { @@ -35,7 +35,7 @@ public function getItem($key) Di::getLogger()->critical("An error occurred getting " . $key . " from redis."); Di::getLogger()->critical($e->getMessage()); Di::getLogger()->critical($e->getTraceAsString()); - return new Item($key); + return null; } } diff --git a/tests/Suite/Adapter/RedisAdapterTest.php b/tests/Suite/Adapter/RedisAdapterTest.php index 8b6295c5..ed5d95aa 100644 --- a/tests/Suite/Adapter/RedisAdapterTest.php +++ b/tests/Suite/Adapter/RedisAdapterTest.php @@ -50,7 +50,7 @@ public function testRedisWithOnlyParameters() $predisClient->set('this_is_a_test_key', 'this-is-a-test-value'); $value = $predis->getItem('this_is_a_test_key'); - $this->assertEquals('this-is-a-test-value', $value->get()); + $this->assertEquals('this-is-a-test-value', $value); $predisClient->del('this_is_a_test_key'); } @@ -76,7 +76,7 @@ public function testRedisWithParametersAndPrefix() $predisClient->set('test-redis-assertion.this_is_a_test_key', 'this-is-a-test-value'); $value = $predis->getItem('this_is_a_test_key'); - $this->assertEquals('this-is-a-test-value', $value->get()); + $this->assertEquals('this-is-a-test-value', $value); $predisClient->del('test-redis-assertion.this_is_a_test_key'); } @@ -103,7 +103,7 @@ public function testRedisWithParametersPrefixAndSentinels() $predisClient->set('test-redis-assertion.this_is_a_test_key', 'this-is-a-test-value'); $value = $predis->getItem('this_is_a_test_key'); - $this->assertEquals('this-is-a-test-value', $value->get()); + $this->assertEquals('this-is-a-test-value', $value); $predisClient->del('test-redis-assertion.this_is_a_test_key'); } diff --git a/tests/Suite/Redis/PRedisReadOnlyMock.php b/tests/Suite/Redis/PRedisReadOnlyMock.php index 6fd43f73..84e7a377 100644 --- a/tests/Suite/Redis/PRedisReadOnlyMock.php +++ b/tests/Suite/Redis/PRedisReadOnlyMock.php @@ -16,7 +16,7 @@ public function __construct(PRedis $predis) /** * @param string $key - * @return \SplitIO\Component\Cache\Item + * @return string */ public function getItem($key) { diff --git a/tests/Suite/Redis/SafeRedisWrapperTest.php b/tests/Suite/Redis/SafeRedisWrapperTest.php index 451b59ed..f684b01f 100644 --- a/tests/Suite/Redis/SafeRedisWrapperTest.php +++ b/tests/Suite/Redis/SafeRedisWrapperTest.php @@ -40,7 +40,7 @@ public function testAllMethodsException() $refProperty->setValue($predisAdapter, $predisMock); $safeRedisWrapper = new SafeRedisWrapper($predisAdapter); - $this->assertEquals(false, $safeRedisWrapper->getItem("some")->get()); + $this->assertEquals(false, $safeRedisWrapper->getItem("some")); $this->assertEquals(array(), $safeRedisWrapper->getItems(array("some"))); $this->assertEquals(false, $safeRedisWrapper->isOnList("some", "another")); $this->assertEquals(array(), $safeRedisWrapper->getKeys("some")); From c436e33d5196a9602613b38481c84ae40a6c54d5 Mon Sep 17 00:00:00 2001 From: Matias Melograno Date: Mon, 21 Mar 2022 13:09:46 -0300 Subject: [PATCH 2/2] renamed cache methods --- src/SplitIO/Component/Cache/Pool.php | 8 ++--- src/SplitIO/Component/Cache/SegmentCache.php | 2 +- src/SplitIO/Component/Cache/SplitCache.php | 8 ++--- .../Adapter/CacheStorageAdapterInterface.php | 4 +-- .../Cache/Storage/Adapter/PRedis.php | 4 +-- .../Storage/Adapter/SafeRedisWrapper.php | 8 ++--- tests/Suite/Adapter/RedisAdapterTest.php | 30 +++++++++---------- tests/Suite/Redis/PRedisReadOnlyMock.php | 8 ++--- tests/Suite/Redis/SafeRedisWrapperTest.php | 4 +-- tests/Suite/Sdk/SdkClientTest.php | 2 +- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/SplitIO/Component/Cache/Pool.php b/src/SplitIO/Component/Cache/Pool.php index cc72fb05..ae850078 100644 --- a/src/SplitIO/Component/Cache/Pool.php +++ b/src/SplitIO/Component/Cache/Pool.php @@ -36,11 +36,11 @@ public function __construct(array $options = array()) * * @return string */ - public function getItem($key) + public function get($key) { $this->assertValidKey($key); Di::getLogger()->debug("Fetching item ** $key ** from cache"); - return $this->adapter->getItem($key); + return $this->adapter->get($key); } /** @@ -59,9 +59,9 @@ public function getItem($key) * key is not found. However, if no keys are specified then an empty * traversable MUST be returned instead. */ - public function getItems(array $keys = array()) + public function fetchMany(array $keys = array()) { - return $this->adapter->getItems($keys); + return $this->adapter->fetchMany($keys); } public function isItemOnList($key, $value) diff --git a/src/SplitIO/Component/Cache/SegmentCache.php b/src/SplitIO/Component/Cache/SegmentCache.php index be3e3d33..8ea79d78 100644 --- a/src/SplitIO/Component/Cache/SegmentCache.php +++ b/src/SplitIO/Component/Cache/SegmentCache.php @@ -36,7 +36,7 @@ public function isInSegment($segmentName, $key) */ public function getChangeNumber($segmentName) { - $since = Di::getCache()->getItem(self::getCacheKeyForSinceParameter($segmentName)); + $since = Di::getCache()->get(self::getCacheKeyForSinceParameter($segmentName)); // empty check for nullable value return (empty($since)) ? -1 : $since; } diff --git a/src/SplitIO/Component/Cache/SplitCache.php b/src/SplitIO/Component/Cache/SplitCache.php index cf6901f1..dd7bac55 100644 --- a/src/SplitIO/Component/Cache/SplitCache.php +++ b/src/SplitIO/Component/Cache/SplitCache.php @@ -37,7 +37,7 @@ private static function getSplitNameFromCacheKey($key) */ public function getChangeNumber() { - $since = Di::getCache()->getItem(self::getCacheKeyForSinceParameter()); + $since = Di::getCache()->get(self::getCacheKeyForSinceParameter()); // empty check for nullable value return (empty($since)) ? -1 : $since; } @@ -49,7 +49,7 @@ public function getChangeNumber() public function getSplit($splitName) { $cache = Di::getCache(); - $cacheItem = $cache->getItem(self::getCacheKeyForSplit($splitName)); + $cacheItem = $cache->get(self::getCacheKeyForSplit($splitName)); return $cacheItem; } @@ -60,7 +60,7 @@ public function getSplit($splitName) public function getSplits($splitNames) { $cache = Di::getCache(); - $cacheItems = $cache->getItems(array_map('self::getCacheKeyForSplit', $splitNames)); + $cacheItems = $cache->fetchMany(array_map('self::getCacheKeyForSplit', $splitNames)); $toReturn = array(); foreach ($cacheItems as $key => $value) { $toReturn[self::getSplitNameFromCacheKey($key)] = $value; @@ -100,7 +100,7 @@ public function trafficTypeExists($trafficType) { $cache = Di::getCache(); - $count = $cache->getItem(self::getCacheKeyForTrafficType($trafficType)); + $count = $cache->get(self::getCacheKeyForTrafficType($trafficType)); // empty check for nullable value return (empty($count) || $count < 1) ? false : true; } diff --git a/src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php b/src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php index 45aec490..c193e191 100644 --- a/src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php +++ b/src/SplitIO/Component/Cache/Storage/Adapter/CacheStorageAdapterInterface.php @@ -16,9 +16,9 @@ public function getKeys($pattern = '*'); * @param string $key * @return string */ - public function getItem($key); + public function get($key); - public function getItems(array $keys); + public function fetchMany(array $keys); /** * @param $key diff --git a/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php b/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php index 8fc7cdb9..baa48086 100644 --- a/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php +++ b/src/SplitIO/Component/Cache/Storage/Adapter/PRedis.php @@ -207,7 +207,7 @@ private function getRedisConfiguration($options) * @param string $key * @return string */ - public function getItem($key) + public function get($key) { return $this->client->get($key); } @@ -225,7 +225,7 @@ public function getItem($key) * * @return array */ - public function getItems(array $keys = array()) + public function fetchMany(array $keys = array()) { $toReturn = array(); if (count($keys) == 0) { diff --git a/src/SplitIO/Component/Cache/Storage/Adapter/SafeRedisWrapper.php b/src/SplitIO/Component/Cache/Storage/Adapter/SafeRedisWrapper.php index e4b12665..9d7a9f4d 100644 --- a/src/SplitIO/Component/Cache/Storage/Adapter/SafeRedisWrapper.php +++ b/src/SplitIO/Component/Cache/Storage/Adapter/SafeRedisWrapper.php @@ -27,10 +27,10 @@ public function __construct(PRedis $cacheAdapter) * @param string $key * @return string */ - public function getItem($key) + public function get($key) { try { - return $this->cacheAdapter->getItem($key); + return $this->cacheAdapter->get($key); } catch (\Exception $e) { Di::getLogger()->critical("An error occurred getting " . $key . " from redis."); Di::getLogger()->critical($e->getMessage()); @@ -48,10 +48,10 @@ public function getItem($key) * * @return array */ - public function getItems(array $keys = array()) + public function fetchMany(array $keys = array()) { try { - return $this->cacheAdapter->getItems($keys); + return $this->cacheAdapter->fetchMany($keys); } catch (\Exception $e) { Di::getLogger()->critical("An error occurred getting " . json_encode($keys) . " from redis."); Di::getLogger()->critical($e->getMessage()); diff --git a/tests/Suite/Adapter/RedisAdapterTest.php b/tests/Suite/Adapter/RedisAdapterTest.php index ed5d95aa..4b14d2be 100644 --- a/tests/Suite/Adapter/RedisAdapterTest.php +++ b/tests/Suite/Adapter/RedisAdapterTest.php @@ -49,7 +49,7 @@ public function testRedisWithOnlyParameters() ]); $predisClient->set('this_is_a_test_key', 'this-is-a-test-value'); - $value = $predis->getItem('this_is_a_test_key'); + $value = $predis->get('this_is_a_test_key'); $this->assertEquals('this-is-a-test-value', $value); $predisClient->del('this_is_a_test_key'); @@ -75,7 +75,7 @@ public function testRedisWithParametersAndPrefix() ]); $predisClient->set('test-redis-assertion.this_is_a_test_key', 'this-is-a-test-value'); - $value = $predis->getItem('this_is_a_test_key'); + $value = $predis->get('this_is_a_test_key'); $this->assertEquals('this-is-a-test-value', $value); $predisClient->del('test-redis-assertion.this_is_a_test_key'); @@ -102,7 +102,7 @@ public function testRedisWithParametersPrefixAndSentinels() ]); $predisClient->set('test-redis-assertion.this_is_a_test_key', 'this-is-a-test-value'); - $value = $predis->getItem('this_is_a_test_key'); + $value = $predis->get('this_is_a_test_key'); $this->assertEquals('this-is-a-test-value', $value); $predisClient->del('test-redis-assertion.this_is_a_test_key'); @@ -232,7 +232,7 @@ public function testRedisWithSentinels() ) )); - $predis->getItem('this_is_a_test_key'); + $predis->get('this_is_a_test_key'); } public function testRedisWithSentinelsAndDistributedStrategy() @@ -248,7 +248,7 @@ public function testRedisWithSentinelsAndDistributedStrategy() ) )); - $predis->getItem('this_is_a_test_key'); + $predis->get('this_is_a_test_key'); } public function testRedisWithEmptyClusters() @@ -322,7 +322,7 @@ public function testRedisWithInvalidKeyHashtagInClusters() ) )); - $predis->getItem('this_is_a_test_key'); + $predis->get('this_is_a_test_key'); } public function testRedisWithInvalidBeginingKeyHashtagInClusters() @@ -342,7 +342,7 @@ public function testRedisWithInvalidBeginingKeyHashtagInClusters() ) )); - $predis->getItem('this_is_a_test_key'); + $predis->get('this_is_a_test_key'); } public function testRedisWithWrongTypeKeyHashtagInClusters() @@ -362,7 +362,7 @@ public function testRedisWithWrongTypeKeyHashtagInClusters() ) )); - $predis->getItem('this_is_a_test_key'); + $predis->get('this_is_a_test_key'); } public function testRedisWithWrongLengthKeyHashtagInClusters() @@ -382,7 +382,7 @@ public function testRedisWithWrongLengthKeyHashtagInClusters() ) )); - $predis->getItem('this_is_a_test_key'); + $predis->get('this_is_a_test_key'); } public function testRedisWithClusters() @@ -398,7 +398,7 @@ public function testRedisWithClusters() ) )); - $predis->getItem('this_is_a_test_key'); + $predis->get('this_is_a_test_key'); } public function testRedisWithoutCustomKeyHashtagClusters() @@ -413,7 +413,7 @@ public function testRedisWithoutCustomKeyHashtagClusters() ) )); - $predis->getItem('this_is_a_test_key'); + $predis->get('this_is_a_test_key'); } public function testRedisWithClustersKeyHashTags() @@ -432,7 +432,7 @@ public function testRedisWithClustersKeyHashTags() ) )); - $predis->getItem('this_is_a_test_key'); + $predis->get('this_is_a_test_key'); } public function testRedisWithClustersKeyHashTagsInvalid() @@ -451,7 +451,7 @@ public function testRedisWithClustersKeyHashTagsInvalid() ) )); - $predis->getItem('this_is_a_test_key'); + $predis->get('this_is_a_test_key'); } public function testRedisWithClustersKeyHashTagsInvalidHashTags() @@ -470,7 +470,7 @@ public function testRedisWithClustersKeyHashTagsInvalidHashTags() ) )); - $predis->getItem('this_is_a_test_key'); + $predis->get('this_is_a_test_key'); } public function testRedisWithClustersKeyHashTagsValid() @@ -486,7 +486,7 @@ public function testRedisWithClustersKeyHashTagsValid() ) )); - $predis->getItem('this_is_a_test_key'); + $predis->get('this_is_a_test_key'); } public function testRedisSSLWithClusterFails() diff --git a/tests/Suite/Redis/PRedisReadOnlyMock.php b/tests/Suite/Redis/PRedisReadOnlyMock.php index 84e7a377..3e859f11 100644 --- a/tests/Suite/Redis/PRedisReadOnlyMock.php +++ b/tests/Suite/Redis/PRedisReadOnlyMock.php @@ -18,9 +18,9 @@ public function __construct(PRedis $predis) * @param string $key * @return string */ - public function getItem($key) + public function get($key) { - return $this->predis->getItem($key); + return $this->predis->get($key); } /** @@ -39,9 +39,9 @@ public function getItem($key) * key is not found. However, if no keys are specified then an empty * traversable MUST be returned instead. */ - public function getItems(array $keys = array()) + public function fetchMany(array $keys = array()) { - return $this->predis->getItems($keys); + return $this->predis->fetchMany($keys); } /** diff --git a/tests/Suite/Redis/SafeRedisWrapperTest.php b/tests/Suite/Redis/SafeRedisWrapperTest.php index f684b01f..473a7aa6 100644 --- a/tests/Suite/Redis/SafeRedisWrapperTest.php +++ b/tests/Suite/Redis/SafeRedisWrapperTest.php @@ -40,8 +40,8 @@ public function testAllMethodsException() $refProperty->setValue($predisAdapter, $predisMock); $safeRedisWrapper = new SafeRedisWrapper($predisAdapter); - $this->assertEquals(false, $safeRedisWrapper->getItem("some")); - $this->assertEquals(array(), $safeRedisWrapper->getItems(array("some"))); + $this->assertEquals(false, $safeRedisWrapper->get("some")); + $this->assertEquals(array(), $safeRedisWrapper->fetchMany(array("some"))); $this->assertEquals(false, $safeRedisWrapper->isOnList("some", "another")); $this->assertEquals(array(), $safeRedisWrapper->getKeys("some")); $this->assertEquals(0, $safeRedisWrapper->rightPushQueue("some", "another")); diff --git a/tests/Suite/Sdk/SdkClientTest.php b/tests/Suite/Sdk/SdkClientTest.php index d0fc2c68..80da42cd 100644 --- a/tests/Suite/Sdk/SdkClientTest.php +++ b/tests/Suite/Sdk/SdkClientTest.php @@ -487,7 +487,7 @@ public function testCacheExceptionReturnsControl() $splitSdk = $splitFactory->client(); $cachePoolMethods = array( - 'getItem', 'getItems', 'isItemOnList', 'getKeys', 'rightPushInList', 'expireKey' + 'get', 'fetchMany', 'isItemOnList', 'getKeys', 'rightPushInList', 'expireKey' ); $cachePool = $this ->getMockBuilder('\SplitIO\Component\Cache\Pool')