Skip to content

* redis cache peer simple implementation, based on Memcached CachePeer #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions core/Cache/BaseAggregateCache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,17 @@ public function getList($indexes)
foreach ($indexes as $index)
$labels[$this->guessLabel($index)][] = $index;

foreach ($labels as $label => $indexList)
if ($this->peers[$label]['object']->isAlive()) {
if ($list = $this->peers[$label]['object']->getList($indexList))
foreach ($labels as $label => $indexList) {

/** @var CachePeer $peer **/
$peer = $this->peers[$label]['object'];

if ($peer->isAlive()) {
if ($list = $peer->getList($indexList))
$out = array_merge($out, $list);
} else
$this->checkAlive();
}

return $out;
}
Expand Down
7 changes: 5 additions & 2 deletions core/Cache/Memcached.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,11 @@ public function delete($index, $time = null)

public function append($key, $data)
{
$packed = serialize($data);

// WHY?
// see $this->store() check type need
// $packed = serialize($data);
$packed = $data;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не уверен что понимаю. Почему теперь здесь $data не сериализуется?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в текущем Memcached при append сериализуется всегда а в store не всегда. string точно не сериализуется. вот и получаем stote('a', 'a'), append('a','a')
get('a') -> as : 1 : "a"

только без пробелов возле ":" а то гитхаб какую-то кнопку рисует

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

думаю, все таки, убирать сериализацию не лучшая затея. взять что-то из метода store - оно в таком случае логичнее, наверно. хотя с другой стороны кто в таком виде вообще использует метод append?


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вот я не понял, почему в store() куча проверок, а в append мы сериализуем все подряд

Для него вообще не должно было работать. у меня и не работало.
$cache->set('a', 'a');
$this->assertEquals($cache->get('a'), 'a');
$cache->append('a', 'a');
$this->assertEquals($cache->get('a'), 'aa');

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а что в ассерте в этом примере получается?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я решил доработать тесты, там еще кое-что выползает ) так что сначала доработаю тесты, а потом уже видно будет

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

окей, подождем

$length = strlen($packed);

// flags and exptime are ignored
Expand Down
Loading