Issues

ZF-12005: getFillingPercentage miscalculation with the WinCache backend

Issue Type: Bug Created: 2012-01-17T10:55:55.000+0000 Last Updated: 2012-03-10T09:59:55.000+0000 Status: Resolved Fix version(s): - 1.11.12 (22/Jun/12)

Reporter: Bruno CHALOPIN (bruno) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Cache

  • cache
  • zf-crteam-review

Related issues: Attachments:

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 :

<pre class="highlight">
--- 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

Posted by Adam Lundrigan (adamlundrigan) on 2012-02-26T04:37:40.000+0000

Added code tag

Posted by Adam Lundrigan (adamlundrigan) on 2012-02-26T04:58:32.000+0000

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

Posted by Marc Bennewitz (private) (mabe) on 2012-03-10T09:59:55.000+0000

ZF2 provides a getCapacity method but it looks ok:

<pre class="highlight">
    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);
        }
    }

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts