krakjoe / apcu

APCu - APC User Cache
Other
964 stars 196 forks source link

Reduce memory usage of apc.php. Fix division by zero error. #477

Closed TysonAndre closed 1 year ago

TysonAndre commented 1 year ago

On tabs other than "User Cache Entries", don't fetch metadata about cache entries.

When running php apc.php in CLI to preview this (adding a cached entry), I noticed a DivisionByZeroError this fixes.

For https://github.com/krakjoe/apcu/issues/365

Testing

https://www.php.net/manual/en/function.apcu-cache-info.php#refsect1-function.apcu-cache-info-changelog

I previewed this in cli for convenience by using the environment instead of an http request

for IMG in {1..3}; do export IMG; php apc.php > $IMG.png; done - the image generation doesn't use apcu_cache_info.

--- a/apc.php
+++ b/apc.php
@@ -95,6 +95,10 @@ $scope_list=array(
        'A' => 'cache_list',
        'D' => 'deleted_list'
 );
+$_REQUEST = $_ENV;
+for ($i = 0; $i < 21; $i++) {
+       apcu_store("k$i", str_repeat('x', 2**$i));
+}