Skip to content

Commit

Permalink
Merge branch 'add-commands' of github.com:M6Web/RedisMock into add-co…
Browse files Browse the repository at this point in the history
…mmands

Conflicts:
	src/M6Web/Component/RedisMock/RedisMock.php
  • Loading branch information
Florent DUBOST committed Jan 17, 2014
2 parents 95fc6a8 + 0ee779f commit 97761a2
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/M6Web/Component/RedisMock/RedisMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ public function sismember($key, $member)

public function lrem($key, $count, $value)
{
$this->deleteOnTtlExpired($key);

if (!isset($this->data[$key]) || !in_array($value, $this->data[$key]) || $this->deleteOnTtlExpired($key)) {
return $this->returnPipedInfo(0);
}
Expand Down Expand Up @@ -271,15 +269,13 @@ public function lrem($key, $count, $value)

public function lpush($key, $value)
{
$this->deleteOnTtlExpired($key);
if ($this->deleteOnTtlExpired($key) || !isset($this->data[$key])) {
$this->data[$key] = array();
}

if (isset($this->data[$key]) && !is_array($this->data[$key])) {
return $this->returnPipedInfo(null);
}

if (!isset($this->data[$key])) {
$this->data[$key] = array();
}
}

array_unshift($this->data[$key], $value);

Expand All @@ -288,16 +284,14 @@ public function lpush($key, $value)

public function rpush($key, $value)
{
$this->deleteOnTtlExpired($key);
if ($this->deleteOnTtlExpired($key) || !isset($this->data[$key])) {
$this->data[$key] = array();
}

if (isset($this->data[$key]) && !is_array($this->data[$key])) {
return $this->returnPipedInfo(null);
}

if (!isset($this->data[$key])) {
$this->data[$key] = array();
}

array_push($this->data[$key], $value);

return $this->returnPipedInfo(count($this->data[$key]));
Expand Down

0 comments on commit 97761a2

Please sign in to comment.