-
Notifications
You must be signed in to change notification settings - Fork 4
/
tarantool.php
37 lines (25 loc) · 991 Bytes
/
tarantool.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
// tarantool 1.10
// https://en.wikipedia.org/wiki/Tarantool
require(__DIR__ . '/vendor/autoload.php');
use Tarantool\Client\Client;
$start = time();
$client = Client::fromDefaults();
$client->evaluate("s = box.schema.space.create('visits')");
$client->evaluate("p = s:create_index('primary', {type = 'hash', parts = {1, 'unsigned'}})");
$space = $client->getSpace('visits');
$i = 1;
while ($visitsData = @file_get_contents("data/visits_$i.json")) {
$visitsData = json_decode($visitsData, true);
foreach ($visitsData['visits'] as $k => $row) {
$space->insert([$row['id'], $row['user'], $row['location'], $row['mark'], $row['visited_at']]);
}
echo "$i\n";
$i++;
}
unset($visitsData);
echo 'init time: ' . (time() - $start) . ', memory: ' . intval(memory_get_usage() / 1000000) . "\n";
# /etc/tarantool/instances.available/example.lua:
# memtx_memory = 1024 * 1024 * 1024;
# memtx_max_tuple_size = 1024 * 1024 * 1024;
# tarantoolctl start example