File: iterator_010.phpt

package info (click to toggle)
php-apcu 5.1.24-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 840 kB
  • sloc: ansic: 4,414; php: 907; xml: 766; makefile: 2
file content (63 lines) | stat: -rw-r--r-- 942 bytes parent folder | download | duplicates (4)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--TEST--
APC: APCIterator shows entries older than global TTL
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
if (!function_exists('apcu_inc_request_time')) die('skip APC debug build required');
?>
--INI--
apc.enabled=1
apc.enable_cli=1
apc.use_request_time=1
apc.ttl=1
--FILE--
<?php

function printInfo() {
    $it = new APCuIterator();
    $keys = array_keys(iterator_to_array($it));
    sort($keys);
    var_dump($keys);
    echo "Total: {$it->getTotalCount()}\n\n";
}

apcu_store("no_ttl", "a");
apcu_store("ttl", "a", 3);

echo "Initial state:\n";
printInfo();

echo "T+2:\n";
apcu_inc_request_time(2);
printInfo();

echo "T+4:\n";
apcu_inc_request_time(2);
printInfo();

?>
--EXPECT--
Initial state:
array(2) {
  [0]=>
  string(6) "no_ttl"
  [1]=>
  string(3) "ttl"
}
Total: 2

T+2:
array(2) {
  [0]=>
  string(6) "no_ttl"
  [1]=>
  string(3) "ttl"
}
Total: 2

T+4:
array(1) {
  [0]=>
  string(6) "no_ttl"
}
Total: 1