Issues

ZF-12005: getFillingPercentage miscalculation with the WinCache backend

Description

Hi,

the getFillingPercentage method of the WinCache backend of Zend_Cache don't calculate the filling percentage but the free memory percentage. Here's the patch :


--- a/vendors/Zend/Cache/Backend/WinCache.php
+++ b/vendors/Zend/Cache/Backend/WinCache.php
@@ -185,7 +185,7 @@ class Zend_Cache_Backend_WinCache extends Zend_Cache_Backend implements Zend_Cac
     {
         $mem = wincache_ucache_meminfo();
         $memSize = $mem['memory_total'];
-        $memUsed = $mem['memory_free'];
+        $memUsed = $mem['memory_total'] - $mem['memory_free'];
         if ($memSize == 0) {
             Zend_Cache::throwException('can\'t get WinCache memory size');
         }

Comments

Added code tag

Fixed in trunk r24651 Merged to release-1.11 in r24653

No ZF2 PR as Zend\Cache\Storage\Adapter\WinCache does not provide a filling percentage getter

ZF2 provides a getCapacity method but it looks ok:


    public function getCapacity(array $options = array())
    {
        $args = new ArrayObject(array(
            'options' => & $options,
        ));

        try {
            $eventRs = $this->triggerPre(__FUNCTION__, $args);
            if ($eventRs->stopped()) {
                return $eventRs->last();
            }

            $mem    = wincache_ucache_meminfo ();
            $result = array(
                'free'  => $mem['memory_free'],
                'total' => $mem['memory_total'],
            );
            return $this->triggerPost(__FUNCTION__, $args, $result);
        } catch (\Exception $e) {
            return $this->triggerException(__FUNCTION__, $args, $e);
        }
    }