Home > Software design >  Unexpected cache in PHP class Cake PHP 2
Unexpected cache in PHP class Cake PHP 2

Time:07-09

I'm working in a Cake PHP 2.10 application, I have a PHP class called CommissionsConsolidationReport and I need to use the Cake PHP cache feature, but when trying to do Cache::read() and Cache::write() an error is thrown in my error.log saying "Unexpected Cache" despite using App::uses('Cache') at the top of my file.

What am I missing?

<?php

App::uses('ClassRegistry', 'Utility', 'Cache');

class CommissionsConsolidationReport
{
        /**
         * Get applications
         *
         * @return array
         */
        private function getApplications()
        {
                ClassRegistry::init('Cache');

                
                $result = Cache::read('newest_posts', 'long');
                if (!$result) {
                        $result = 'is set'
                        Cache::write('newest_posts', $result, 'long');
                }

                var_dump($result);
        }
}

CodePudding user response:

Need to configure default cache engine or custom cache engine

  • Related