function __construct($host, $port, $timeout_ms = 2000) { parent::__construct($host, $port, $timeout_ms); $this->easy(); }
<?php $ssdb_handle = new SSDB(); $ssdb_handle->connect('127.0.0.1', 8888); $ssdb_handle->option(SSDB::OPT_PREFIX, 'test_'); #设置value压缩模式 使用压缩会导致类似substr命令返回出错 #$ssdb_handle->option(SSDB::OPT_SERIALIZER, SSDB::SERIALIZER_PHP); echo "version" . PHP_EOL; $result = $ssdb_handle->version(); var_dump($result); $result = $ssdb_handle->auth("xingqiba"); var_dump($result); $result = $ssdb_handle->set("name", "xingqiba"); var_dump($result); echo "substr" . PHP_EOL; $result = $ssdb_handle->substr("name"); var_dump($result); echo "substr" . PHP_EOL; $result = $ssdb_handle->substr("name", 1, 3); var_dump($result); $result = $ssdb_handle->get("name"); var_dump($result); $result = $ssdb_handle->setnx("location", "shanghai"); var_dump($result); $result = $ssdb_handle->get("location"); var_dump($result); $result = $ssdb_handle->del("location"); var_dump($result); $result = $ssdb_handle->get("location"); var_dump($result); $result = $ssdb_handle->get("blog");
<?php $ssdb_handle = new SSDB('127.0.0.1', 8888); $i = 1; while ($i < 1000000) { $result = $ssdb_handle->geo_set('geo_test', 'b' . $i, 31.196456, 121.515778); //echo $result . PHP_EOL; $i++; } echo "finished" . PHP_EOL;
<?php $socket_handle = new SSDB('192.168.1.53'); $socket_handle->option(SSDB::OPT_READ_TIMEOUT, 3); $result = $socket_handle->write("7\nversion\n\n"); var_dump($result); $result = $socket_handle->read(100); var_dump($result);
<?php ini_set('memory_limit', -1); $ssdb_handle = new SSDB('127.0.0.1', 8888); $result = $ssdb_handle->geo_clear('geo_test'); var_dump($result); $result = $ssdb_handle->geo_del('geo_test', 'a'); var_dump($result); //临沂四村 $result = $ssdb_handle->geo_set('geo_test', 'a', 31.197452, 121.515095); echo $result . PHP_EOL; $result = $ssdb_handle->geo_get('geo_test', 'a'); print_r($result); //临沂五村 $result = $ssdb_handle->geo_set('geo_test', 'b', 31.196456, 121.515778); echo $result . PHP_EOL; $result = $ssdb_handle->geo_get('geo_test', 'b'); print_r($result); //临沂五村 $result = $ssdb_handle->geo_set('geo_test', 'bb', 31.196456, 121.515778); echo $result . PHP_EOL; $result = $ssdb_handle->geo_get('geo_test', 'bb'); print_r($result); //临沂六村 $result = $ssdb_handle->geo_set('geo_test', 'c', 31.197159, 121.518015); echo $result . PHP_EOL; $result = $ssdb_handle->geo_get('geo_test', 'c'); print_r($result); //临沂路 $result = $ssdb_handle->geo_set('geo_test', 'd', 31.196282, 121.51563); echo $result . PHP_EOL;
$ssdb = new SSDB($host, $port); } catch (Exception $e) { die(__LINE__ . ' ' . $e->getMessage()); } foreach ($data as $k => $v) { $ret = $ssdb->set($k, $v); if ($ret === false) { echo "error\n"; break; } } $ssdb->close(); speed('set speed: ', count($data)); speed(); try { $ssdb = new SSDB($host, $port); } catch (Exception $e) { die(__LINE__ . ' ' . $e->getMessage()); } foreach ($data as $k => $v) { $ret = $ssdb->get($k); if ($ret === false) { echo "error\n"; break; } } $ssdb->close(); speed('get speed: ', count($data)); function speed($msg = null, $count = 0) { static $stime;