CodeIgniter Forums
Cache doesn't work, InfoCache.php throws errors - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Cache doesn't work, InfoCache.php throws errors (/showthread.php?tid=91097)



Cache doesn't work, InfoCache.php throws errors - minsk832 - 06-16-2024

I'm trying to figure out why my caching isn't working. It's set to filesystem
Code:
public string $handler = 'file';)
I haven't changed anything in the initial app/Config/Cache.php. .env is set to: CI_ENVIRONMENT = development . I haven't found any indication in the help at https://www.codeigniter.com/user_guide/libraries/caching.html or https://www.codeigniter.com/user_guide/general/caching.html that there are automatic differences depending on the ENV.

In the controller method I use:
Code:
$this->cachePage($this->cacheTTL);

The controller property is defined as:
Code:
protected $cacheTTL = 604800;

Nothing is created under writeable/cache.

In the console,
Code:
php spark cache:info
results in:
Quote:CodeIgniter v4.5.2 Command Line Tool - Server Time: 2024-06-16 16:02:35 UTC+02:00

[Error]
Object of class CodeIgniter\Cache\Handlers\DummyHandler could not be converted to string
at SYSTEMPATH\Commands\Cache\InfoCache.php:70

Backtrace:
  1    SYSTEMPATH\CLI\Commands.php:70
      CodeIgniter\Commands\Cache\InfoCache()->run([])

  2    SYSTEMPATH\CLI\Console.php:48
      CodeIgniter\CLI\Commands()->run('cache:info', [])

  3    SYSTEMPATH\Boot.php:351
      CodeIgniter\CLI\Console()->run()

  4    SYSTEMPATH\Boot.php:104
      CodeIgniter\Boot::runCommand(Object(CodeIgniter\CLI\Console))

  5    ROOTPATH\spark:84
      CodeIgniter\Boot::bootSpark(Object(Config\Paths))

This error should not actually occur because there is a check:
Code:
if ($config->handler !== 'file') {
    CLI::error('This command only supports the file cache handler.');

    return;
}
Does anyone know what's going wrong here? I'm using Windows 11 Pro with a Wamp Server.

Edit:
Code:
var_dump(cache()->isSupported('file'));

=> bool(true)

I do not get it Sad

Solution:

Through further debugging, I discovered that the write protection is always set by Windows Explorer. I was able to solve it using cmd and then

Code:
attrib -r "C:\path\ci4directory\writable" /S /D