Cache with file system
Cache with file system., (*1)
In cases you don't want to have other dependencies or don't want to waste your RAM., (*2)
gzcompress
composer require ark/filecache
<?php use Ark\Filecache\FileCache; $cache = new FileCache([ 'root' => '/path/to/cache/root', // Cache root 'ttl' => 0, // Time to live 'compress' => false, // Compress data with gzcompress or not 'serialize' => 'json', // How to serialize data: json, php, raw ]); $cache->set('key1', 'value1'); $cache->get('key1'); // Set TTL and compression $cache->set('key2', array('hello', 'world'), array( 'ttl' => 10, 'compress' => true )); sleep(11); $cache->get('key2'); $cache->delete('key1'); $cache->clear(); // clear all caches by removing the root path of the cache