forked from php-memcached-dev/php-memcached
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
144 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--TEST-- | ||
Memcached getDelayed non string keys | ||
--SKIPIF-- | ||
<?php if (!extension_loaded("memcached")) print "skip"; ?> | ||
--FILE-- | ||
<?php | ||
$m = new Memcached(); | ||
$m->addServer('localhost', 11211, 1); | ||
|
||
class Bar { | ||
public function __toString() { | ||
return 'bar'; | ||
} | ||
} | ||
|
||
$data = array( | ||
'foo' => 'foo-data', | ||
'bar' => 'bar-data', | ||
3 => '3-data', | ||
); | ||
|
||
foreach ($data as $k => $v) { | ||
$m->set($k, $v, 3600); | ||
} | ||
|
||
function myfunc() { | ||
$datas = func_get_args(); | ||
if (isset($datas[1])) { | ||
unset($datas[1]['cas']); | ||
var_dump($datas[1]); | ||
} | ||
} | ||
|
||
$keys = array('foo', | ||
$k = new Bar(), | ||
3, | ||
); | ||
|
||
$m->getDelayed($keys, false, 'myfunc'); | ||
|
||
if ($keys[0] !== 'foo') { | ||
echo "String 'foo' was coerced to: "; | ||
var_dump($keys[0]); | ||
} | ||
|
||
if (!$keys[1] instanceof Bar) { | ||
echo "Object was coerced to: "; | ||
var_dump($keys[1]); | ||
} | ||
|
||
if ($keys[2] !== 3) { | ||
echo "Integer 3 was coerced to: "; | ||
var_dump($keys[2]); | ||
} | ||
--EXPECT-- | ||
array(2) { | ||
["key"]=> | ||
string(3) "foo" | ||
["value"]=> | ||
string(8) "foo-data" | ||
} | ||
array(2) { | ||
["key"]=> | ||
string(3) "bar" | ||
["value"]=> | ||
string(8) "bar-data" | ||
} | ||
array(2) { | ||
["key"]=> | ||
string(1) "3" | ||
["value"]=> | ||
string(6) "3-data" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--TEST-- | ||
Memcached::getMulti() | ||
--SKIPIF-- | ||
<?php if (!extension_loaded("memcached")) print "skip"; ?> | ||
--FILE-- | ||
<?php | ||
$m = new Memcached(); | ||
$m->addServer('localhost', 11211, 1); | ||
|
||
class Foo { | ||
function __toString() { | ||
return 'a-foo'; | ||
} | ||
} | ||
|
||
$data = array(); | ||
for ($i = 0; $i < 1000; $i++) { | ||
$data['key' . $i] = 'value' . $i; | ||
} | ||
$data['a-foo'] = 'a-last'; | ||
var_dump($m->setMulti($data)); | ||
|
||
$keys = array_keys($data); | ||
$keys['last'] = new Foo(); | ||
|
||
$v = $m->getMulti($keys); | ||
var_dump(is_array($v)); | ||
var_dump($m->getResultCode() == Memcached::RES_SUCCESS); | ||
if (is_array($v)) { | ||
foreach ($v as $key => $value) { | ||
if (!isset($data[$key]) or $value !== $data[$key]) { | ||
echo "mismatch \$data['$key'] = \n"; | ||
var_dump($data[$key]); | ||
var_dump($value); | ||
} | ||
} | ||
} else { | ||
echo "Result not an array\n"; | ||
} | ||
|
||
var_dump(is_object($keys['last'])); | ||
|
||
--EXPECT-- | ||
bool(true) | ||
bool(true) | ||
bool(true) | ||
bool(true) |