nicolasff/phpredis — Issue #87: RedisArray, discard - strange behaviour
Author: trong
Created: 2011-11-24 05:28:14+00:00
State: open

Hello, Nicolas!

Test code:

```php
$key = 'test_err';

$ra = new RedisArray(array('127.0.0.1:6379'));
echo ($ra->set($key, 'test')) ? 'Set: OK' : 'Set: Failed', "\n";
echo "\nBefore multi: \n";
var_dump($ra->get($key));

$ra->watch($key);

echo "\nAfter watch: \n";
var_dump($ra->get($key));

$ret = $ra->multi($ra->_target($key))->set($key, 'test1')->exec();
echo "\nRet of exec: \n";
var_dump($ret);

echo "\nGet after exec: \n";
var_dump($ra->get($key));

$ra->watch($key);

echo "\nAfter second watch: \n";
var_dump($ra->get($key));

$ret = $ra->multi($ra->_target($key))->set($key, 'test1')->discard();
echo "\nRet after discard: \n";
var_dump($ret);

echo "\nGet after discard: \n";
var_dump($ra->get($key));
```

Output:

```
Set: OK

Before multi:
string(4) 'test'

After watch:
string(4) 'test'

Ret of exec:
array(1) {
[0] =>
bool(true)
}

Get after exec:
string(5) 'test1'

After second watch:
string(5) 'test1'

Ret after discard:
class RedisArray#1 (1) {
public $socket => resource(6) of type (Redis Array)
}

Get after discard:
class RedisArray#1 (1) {
public $socket => resource(6) of type (Redis Array)
}
```

I can't understand why I get the RedisArray object instead of 'test1' in the last line of test code :(