make-million.php ➔ generateAddressFixture()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
1
<?php
2
if (PHP_SAPI != 'cli') {
3
    die('no trespass! call the administrator!');
4
}
5
6
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bootstrap.php';
7
8
set_time_limit(0);
9
ini_set("memory_limit", "-1");
10
11
function generateAddressFixture()
12
{
13
    return array(
14
        // Random string with length between 8 and 16
15
        substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'), 0, rand(8, 16)),
16
        // Random five digit number
17
        sprintf('%05d', rand(1, 99999)),
18
        // Random string with length between 8 and 16
19
        substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'), 0, rand(8, 16)),
20
        // Random string with length 2
21
        substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'), 0, 2)
22
    );
23
}
24
25
$db = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'app.db4';
26
$cache = new \PhpDbaCache\Cache($db, 'db4', 'c-', true);
27
28
for ($key = 0; $key < 1000000; $key++) {
29
    print_r($value = generateAddressFixture());
30
    print 'SAVED=' . (int)$cache->put($key, $value, rand(1, 21600)) . PHP_EOL;
31
}
32
33
$cache->closeDba();
34
35
die('END');
36