From 974b650d8048ec294e6e72a75f710cca21a3b06a Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Wed, 10 Feb 2016 14:44:39 -0800 Subject: [PATCH 1/5] Updated Stash to v0.14 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fe7e9fd..a3260b2 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ ], "require": { "php": "^5.4|^7.0", - "tedivm/stash": "0.13.*", + "tedivm/stash": "0.14.*", "symfony/config": "~2.1|~3.0", "symfony/http-kernel": "~2.1|~3.0", "symfony/dependency-injection": "~2.1|~3.0" From 85fe91436feb3f970739af97eede6b8e54fab467 Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Wed, 10 Feb 2016 16:52:24 -0800 Subject: [PATCH 2/5] Added $key argument, removed custom clear (inherit from Pool) --- Service/CacheService.php | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/Service/CacheService.php b/Service/CacheService.php index 399c69b..825e3dc 100644 --- a/Service/CacheService.php +++ b/Service/CacheService.php @@ -56,16 +56,10 @@ public function __construct($name, DriverInterface $driver = null, CacheTracker /** * {@inheritdoc} */ - public function getItem() + public function getItem($key) { - $args = func_get_args(); - - // check to see if a single array was used instead of multiple arguments - if(count($args) == 1 && is_array($args[0])) - $args = $args[0]; - /** @var CacheItem $item */ - $item = parent::getItem($args); + $item = parent::getItem($key); if (isset($this->tracker)) { $item->setCacheTracker($this->tracker); @@ -74,21 +68,6 @@ public function getItem() return $item; } - /** - * {@inheritdoc} - */ - public function clear() - { - $args = func_get_args(); - if (count($args) === 0) { - return $this->flush(); - } else { - $item = $this->getItem($args); - - return $item->clear(); - } - } - /** * Returns the current list of drivers that the system is able to use. * From f33aa14129faa935fedcd67a2d70c779a022659a Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Wed, 10 Feb 2016 16:53:20 -0800 Subject: [PATCH 3/5] Added Stash API changes from v0.14.0 --- Adapters/DoctrineAdapter.php | 12 +++++------- Tests/Service/CacheServiceTest.php | 14 +++++++++----- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Adapters/DoctrineAdapter.php b/Adapters/DoctrineAdapter.php index bf2bcce..5c2a520 100644 --- a/Adapters/DoctrineAdapter.php +++ b/Adapters/DoctrineAdapter.php @@ -107,9 +107,8 @@ public function save($id, $data, $lifeTime = 0) $id = $this->normalizeId($id); $item = $this->cacheService->getItem($id); - - return $item->set($data, $lifeTime); - + $item->set($data, $lifeTime); + return $this->cacheService->save($item); } /** @@ -118,13 +117,12 @@ public function save($id, $data, $lifeTime = 0) public function delete($id) { $id = $this->normalizeId($id); - - return $this->cacheService->clear($id); + return $this->cacheService->deleteItem($id); } public function deleteAll() { - return $this->flushAll(); + return $this->delete(''); } /** @@ -165,7 +163,7 @@ public function flushAll() protected function normalizeId($id) { $namespace = (isset($this->namespace) && $this->namespace != '') ? $this->namespace : 'default'; - $id = sprintf('zz_%s_zz/%s', $namespace, $id); + $id = sprintf('/zz_%s_zz/%s', $namespace, $id); return $id; } diff --git a/Tests/Service/CacheServiceTest.php b/Tests/Service/CacheServiceTest.php index 62057d0..db0c819 100644 --- a/Tests/Service/CacheServiceTest.php +++ b/Tests/Service/CacheServiceTest.php @@ -78,7 +78,7 @@ public function testCacheService() $this->runCacheCycle($service, 'one', false); $this->runCacheCycle($service, 'two', false); - $this->assertTrue($service->clear('test', 'key', 'one')); + $this->assertTrue($service->deleteItem('test/key/one')); $this->runCacheCycle($service, 'one', true); $this->runCacheCycle($service, 'two', false); @@ -118,17 +118,18 @@ public function testServiceGetItemIterator() $service = $this->getCacheService('first'); $service->setDriver(new Ephemeral()); - $iterator = $service->getItemIterator($keys); + $iterator = $service->getItems($keys); $setvalues = $values; foreach ($iterator as $item) { $this->assertTrue($item->isMiss()); $val = array_shift($setvalues); $item->set($val); + $service->save($item); $this->assertEquals($val, $item->get()); } - $iterator2 = $service->getItemIterator($keys); + $iterator2 = $service->getItems($keys); $getvalues = $values; foreach ($iterator2 as $item) { @@ -140,14 +141,17 @@ public function testServiceGetItemIterator() protected function runCacheCycle($service, $num, $ismiss) { - $key = array('test', 'key', $num); + $key = "test/key/$num"; $testData = 'testkey' . $num; $item = $service->getItem($key); $data = $item->get(); $this->assertEquals($ismiss, $item->isMiss()); - $this->assertTrue($item->set($testData)); +// $this->assertTrue($item->set($testData)); + + $item->set($testData); + $service->save($item); $item = $service->getItem($key); $data = $item->get(); From 2df2b28f79b9a12986a58df21dd5f0b714e872d7 Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Wed, 10 Feb 2016 16:53:29 -0800 Subject: [PATCH 4/5] Updated changelog for next release --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed92755..ad6bf7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## Tedivm StashBundle v0.6 Changelog + +### 0.6.1 + +* Brought bundle up to date with the v0.14.0 line of Stash. + + ## Tedivm StashBundle v0.5 Changelog ### 0.5.3 From 561452dee2f8918a9057dd745f66d22be1e1a008 Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Wed, 10 Feb 2016 17:00:17 -0800 Subject: [PATCH 5/5] Formatting --- Adapters/DoctrineAdapter.php | 2 ++ CONTRIBUTING.md | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Adapters/DoctrineAdapter.php b/Adapters/DoctrineAdapter.php index 5c2a520..cb4278f 100644 --- a/Adapters/DoctrineAdapter.php +++ b/Adapters/DoctrineAdapter.php @@ -108,6 +108,7 @@ public function save($id, $data, $lifeTime = 0) $id = $this->normalizeId($id); $item = $this->cacheService->getItem($id); $item->set($data, $lifeTime); + return $this->cacheService->save($item); } @@ -117,6 +118,7 @@ public function save($id, $data, $lifeTime = 0) public function delete($id) { $id = $this->normalizeId($id); + return $this->cacheService->deleteItem($id); } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 527199b..36bec75 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,4 +51,4 @@ To call phpunit directly: To call php-cs-fixer directly to fix any code style issues automatically: - ./vendor/bin/php-cs-fixer fix ./ --level="all" -vv --dry-run + ./vendor/bin/php-cs-fixer fix ./ --level="all" -vv