note 68581 added to function.memcache-set
| From: | mars at joyinter dot com | Date: | Wed, 02 Aug 2006 14:06:13 +0000 |
| Subject: | note 68581 added to function.memcache-set | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115484@lists.php.net to get a copy of this message | ||
Something's really weird between Memcached API between PHP and java(com.danga.MemCached)
first, when PHPAPI set a pair of key and value,java can't read it:
PHP code:
<?php
/* OO API */
$memcache_obj = new Memcache;
/* connect to memcached server */
$memcache_obj->connect('192.168.0.200', 11211);
/*
set value of item with key 'var_key', using on-the-fly compression
expire time is 50 seconds
*/
$memcache_obj->set('var_key', 'some really big variable');
?>
Java code:
try {
SockIOPool pool = SockIOPool.getInstance();
pool.setServers(new String[]{"192.168.0.200:11211"});
pool.initialize();
client = new MemCachedClient();
System.out.println("value="+client.get("var_key"));
}
catch (Exception e) {
e.printStackTrace();
}
The result turns out to be : value=null
but when use javacode:
System.out.println(client.replace("var_key", "xxx"));
System.out.println("value="+client.get("var_key"));
The result:
true
xxx
It indicates java actually read the key!?
On the other hand, when Java set a pair of key and value, php read it, the value will have an extra
char at the front of actual value:
Java Code:
try {
SockIOPool pool = SockIOPool.getInstance();
pool.setServers(new String[]{"192.168.0.200:11211"});
pool.initialize();
client = new MemCachedClient();
client.set("somekey", "somevalue");
}
catch (Exception e) {
e.printStackTrace();
}
PHP Code:
<?php
/* OO API */
$memcache_obj = new Memcache;
$memcache_obj->connect('192.168.0.200', 11211);
$value = $memcache_obj->get('somekey');
echo "value=$value\r\nFirst char's ASCII value is ".ord($value[0]);
?>
value=somevalue
First char's ASCII value is 6
Is anybody able to explain that?
----
Server IP: 66.163.161.117
Probable Submitter: 219.142.230.27
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.memcache-set.php
Edit -- https://master.php.net/note/edit/68581
Del: integrated -- https://master.php.net/note/delete/68581/integrated
Del: useless -- https://master.php.net/note/delete/68581/useless
Del: bad code -- https://master.php.net/note/delete/68581/bad+code
Del: spam -- https://master.php.net/note/delete/68581/spam
Del: non-english -- https://master.php.net/note/delete/68581/non-english
Del: in docs -- https://master.php.net/note/delete/68581/in+docs
Del: other reasons-- https://master.php.net/note/delete/68581
Reject -- https://master.php.net/note/reject/68581
Search -- https://master.php.net/manage/user-notes.php