File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ if (PHP_DDTRACE != 'no') {
6969 DDTRACE_TRACER_SOURCES += " tracer_otel_config.c";
7070 DDTRACE_TRACER_SOURCES += " profiling.c";
7171 DDTRACE_TRACER_SOURCES += " random.c";
72+ DDTRACE_TRACER_SOURCES += " routing_cache.c";
7273 DDTRACE_TRACER_SOURCES += " rule_matching.c";
7374 DDTRACE_TRACER_SOURCES += " serializer.c";
7475 DDTRACE_TRACER_SOURCES += " span.c";
Original file line number Diff line number Diff line change 4141 __DIR__ . '/../DDTrace/Propagators/TextMap.php ' ,
4242 __DIR__ . '/../DDTrace/ScopeManager.php ' ,
4343 __DIR__ . '/../DDTrace/Tracer.php ' ,
44+ __DIR__ . '/../DDTrace/Util/RouteNormalizer.php ' ,
4445];
Original file line number Diff line number Diff line change 11--TEST--
2- DDTrace\routing_cache evicts least-recently-used entry when capacity (500) is exceeded
2+ DDTrace\routing_cache evicts the oldest inserted entry when capacity (500) is exceeded
33--FILE--
44<?php
55
6- // Fill the cache to capacity (500 entries)
6+ // Fill the cache to capacity (500 entries); key0 is the oldest inserted
77for ($ i = 0 ; $ i < 500 ; $ i ++) {
88 DDTrace \routing_cache_set ("key $ i " , "value $ i " );
99}
1010
11- // key0 is the LRU — access key1..key499 to keep them hot, leaving key0 as LRU
12- // Actually they were inserted oldest-first, so key0 is at tail (LRU).
13- // Verify key0 is still present before eviction
11+ // key0 is present before any eviction
1412var_dump (DDTrace \routing_cache_get ('key0 ' ));
1513
16- // Access key0 to move it to MRU position so key1 becomes LRU
17- DDTrace \routing_cache_get ('key0 ' );
18-
19- // Insert one more entry; key1 should be evicted (it's now LRU)
14+ // Insert one more entry; key0 (oldest) should be evicted
2015DDTrace \routing_cache_set ('key500 ' , 'value500 ' );
2116
22- var_dump (DDTrace \routing_cache_get ('key1 ' )); // evicted
23- var_dump (DDTrace \routing_cache_get ('key0 ' )); // still present (was accessed)
17+ var_dump (DDTrace \routing_cache_get ('key0 ' )); // evicted
18+ var_dump (DDTrace \routing_cache_get ('key1 ' )); // still present
2419var_dump (DDTrace \routing_cache_get ('key500 ' )); // newly inserted
2520
2621?>
2722--EXPECT--
2823string(6) "value0"
2924bool(false)
30- string(6) "value0 "
25+ string(6) "value1 "
3126string(8) "value500"
You can’t perform that action at this time.
0 commit comments