RedUNIT\Base\Writecache::testCacheSize PHP Method

testCacheSize() public method

Avoiding potential memory leaks. (Issue #424).
public testCacheSize ( ) : void
return void
    public function testCacheSize()
    {
        R::nuke();
        R::useWriterCache(TRUE);
        $writer = R::getWriter();
        $bean = R::dispense('bean');
        $bean->prop = 1;
        R::store($bean);
        $writer->flushCache(20);
        $count = $writer->flushCache();
        asrt($count, 0);
        R::find('bean', ' prop < ? ', array(1));
        $count = $writer->flushCache();
        asrt($count, 2);
        R::find('bean', ' prop < ? ', array(2));
        $count = $writer->flushCache();
        asrt($count, 5);
        R::find('bean', ' prop < ? ', array(2));
        $count = $writer->flushCache();
        asrt($count, 5);
        for ($i = 0; $i < 40; $i++) {
            R::find('bean', ' prop < ? ', array($i));
        }
        $count = $writer->flushCache();
        asrt($count, 85);
        for ($i = 0; $i < 120; $i++) {
            R::find('bean', ' prop < ? ', array($i));
        }
        $count = $writer->flushCache(1);
        asrt($count, 85);
        for ($i = 0; $i < 20; $i++) {
            R::find('bean', ' prop < ? ', array($i));
        }
        $count = $writer->flushCache(20);
        asrt($count, 9);
    }