Skip to content

Commit

Permalink
Update for 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nilportugues committed Mar 18, 2016
1 parent 4a1c11e commit 2345860
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}
],
"require": {
"nilportugues/repository": "^2.1",
"nilportugues/repository": "^2.2",
"tedivm/stash": "v0.14.*"
},
"require-dev": {
Expand Down
14 changes: 5 additions & 9 deletions src/RepositoryCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
use NilPortugues\Foundation\Domain\Model\Repository\Contracts\ReadRepository;
use NilPortugues\Foundation\Domain\Model\Repository\Contracts\Sort;
use NilPortugues\Foundation\Domain\Model\Repository\Contracts\WriteRepository;
use Psr\Cache\CacheItemPoolInterface;
use Stash\Interfaces\PoolInterface;

class RepositoryCache implements ReadRepository, WriteRepository, PageRepository
{
/**
* @var PoolInterface
* @var CacheItemPoolInterface
*/
protected $cache;
/**
Expand Down Expand Up @@ -226,23 +227,18 @@ public function removeAll(Filter $filter = null)
/**
* {@inheritdoc}
*/
public function findByDistinct(
Fields $distinctFields,
Filter $filter = null,
Sort $sort = null,
Fields $fields = null
) {
public function findByDistinct(Fields $distinctFields, Filter $filter = null, Sort $sort = null) {
$cachedItem = $this->cache->getItem(
$this->cacheNamespaceFindByDistinct.md5(
serialize($filter).serialize($sort).serialize($fields).serialize($distinctFields)
serialize($filter).serialize($sort).serialize($distinctFields)
)
);

if (!$cachedItem->isMiss() && null !== ($result = $cachedItem->get())) {
return $result;
}

$result = $this->repository->findByDistinct($distinctFields, $filter, $sort, $fields);
$result = $this->repository->findByDistinct($distinctFields, $filter, $sort);
$cachedItem->set($result, $this->cacheTime);

return $result;
Expand Down

0 comments on commit 2345860

Please sign in to comment.