PHP code example of boruta / timebase
1. Go to this page and download the library: Download boruta/timebase library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
boruta / timebase example snippets
$timebase = new Boruta\Timebase\Timebase(__DIR__ . '/database/');
$timebase->insert()->set('test')->execute();
$result = $timebase->search()->execute();
array(2) {
["timestamp"]=>
int(1612022907)
["value"]=>
string(4) "test"
}
$timebase = new Boruta\Timebase\Timebase(__DIR__ . '/database/', $logger);
$timebase->insert()
->set(123) // or ->set('test') or ->set(['test' => 123]) etc.
->execute();
$timebase->insert()
->storage(['test']) // storage path: __DIR__ . '/database/test/'
->set('test')
->execute();
$timebase->insert()
->storage(['level0', 'level1']) // storage path: __DIR__ . '/database/level0/level1/'
->set('test')
->execute();
$result = $timebase->search()
->storage(['test']) // storage path: __DIR__ . '/database/test/'
->execute();
$result = $timebase->search()
->storage(['level0', 'level1']) // storage path: __DIR__ . '/database/level0/level1/'
->execute();
$timebase->insert()
->timestamp(1612022907)
->set('test')
->execute();
$result = $timebase->search()
->timestamp(1612022907)
->execute();
$result = $timebase->search()
->timestamp(1612022907)
->all()
->execute();
array(3) {
["timestamp"]=>
int(1612012606)
["value"]=>
string(4) "test"
["all"]=>
array(2) {
[0]=>
string(4) "test"
[1]=>
string(4) "test"
}
}
$result = $timebase->search()
->strategy(\Boruta\Timebase\Common\Constant\SearchStrategyConstant::NEAREST)
->timestamp(1612022907)
->execute();
$result = $timebase->search()
->strategy(\Boruta\Timebase\Common\Constant\SearchStrategyConstant::EXACT)
->timestamp(1612022907)
->execute();
$result = $timebase->search()
->strategy(\Boruta\Timebase\Common\Constant\SearchStrategyConstant::EARLIER)
->timestamp(1612022907)
->execute();
$result = $timebase->search()
->strategy(\Boruta\Timebase\Common\Constant\SearchStrategyConstant::LATER)
->timestamp(1612022907)
->execute();