Skip to content

Commit

Permalink
Merge pull request #94 from tedious/stash_v0_14
Browse files Browse the repository at this point in the history
Updated Stash to v0.14
  • Loading branch information
tedivm committed Feb 11, 2016
2 parents 7de7180 + 561452d commit 99e435e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 35 deletions.
10 changes: 5 additions & 5 deletions Adapters/DoctrineAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public function save($id, $data, $lifeTime = 0)

$id = $this->normalizeId($id);
$item = $this->cacheService->getItem($id);
$item->set($data, $lifeTime);

return $item->set($data, $lifeTime);

return $this->cacheService->save($item);
}

/**
Expand All @@ -119,12 +119,12 @@ 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('');
}

/**
Expand Down Expand Up @@ -165,7 +165,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;
}
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 2 additions & 23 deletions Service/CacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
*
Expand Down
14 changes: 9 additions & 5 deletions Tests/Service/CacheServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 99e435e

Please sign in to comment.