<?php $namespace = 'bbs'; $object_id = 'test'; $key = 'KEY123456'; $value = '123456789012345'; $fdht = new FastDHT(0); if (($result = $fdht->set($namespace, $object_id, $key, $value)) != 0) { error_log("fastdht_set fail, errno: {$result}"); } var_dump($fdht->get($namespace, $object_id, $key, false, time() + 30)); var_dump($fdht->inc($namespace, $object_id, $key, 100)); echo "sub_keys: \n"; var_dump($fdht->get_sub_keys($namespace, $object_id, true)); echo 'delete: ' . $fdht->delete($namespace, $object_id, $key) . "\n"; echo "\n"; var_dump($fdht->stat_all()); $fdht->close(); if (($result = fastdht_set($namespace, $object_id, $key, $value)) != 0) { error_log("fastdht_set fail, errno: {$result}"); } $value = fastdht_get($namespace, $object_id, $key, false, time() + 60); if (!is_string($value)) { error_log("fastdht_get fail, errno: {$value}"); } else { echo "value: {$value}\n"; } echo "\n"; $stats = fastdht_stat(0); var_dump($stats); echo "sub_keys: \n";
$namespace = 'user'; $object_id = 'test'; $key_value_pair = array(); $key_value_pair['login'] = '******'; $key_value_pair['reg'] = 1235301445; $key_value_pair['intl'] = 'zh'; $key_value_pair['co'] = 'CN'; $key_value_pair['dz'] = 8; $fdht = new FastDHT(0); $result = $fdht->batch_set($namespace, $object_id, $key_value_pair); if ($result != 0) { var_dump($result); error_log("fastdht_batch_set fail partially"); } $fdht = new FastDHT(0); $key_value_pair = array('login', 'reg', 'intl', 'co', 'city'); $result = $fdht->batch_get($namespace, $object_id, $key_value_pair); var_dump($result); $result = $fdht->batch_delete($namespace, $object_id, $key_value_pair); if ($result != 0) { var_dump($result); error_log("fastdht_batch_delete fail partially"); } $fdht->close(); $key_value_pair = array(); $key_value_pair['login'] = '******'; $key_value_pair['reg'] = 1235301445; $key_value_pair['intl'] = 'zh'; $key_value_pair['co'] = 'CN'; $key_value_pair['dz'] = 8;