use Zend_Cache

ini_set('display_errors', 1);
$backend = 'Cm_Cache_Backend_File';
$frontend = 'Magento\Framework\Cache\Core';
$frontendOptions = [
        'cache_id_prefix' => '7f1_',
        'caching'=>true,
        'lifetime' => 7200,
        'automatic_cleaning_factor' => 0,
        'type' => 'Magento\Framework\Cache\Core'
];
$backendOptions = [
    'cache_dir' => '/var/www/html/m230/var/page_cache_test',
    'hashed_directory_level' => 1,
    'file_name_prefix' => 'magetest'
];

$cache = \Zend_Cache::factory(
    $frontend,
    $backend,
    $frontendOptions,
    $backendOptions,
    true,
    true,
    true
);

var_dump(get_class($cache));

$cache->save('wanttosavedata', 'dataid', ['datatag', 'datatag2']);
echo $cache->load('first');

Ok, we will get these files.

var/page_cache_test
    |-- magetest-tags
        |-- magetest---7f1_datatag
        |-- magetest---7f1_datatag2
    |-- magetest--0
        |-- magetest---7f1_dataid

发表评论

电子邮件地址不会被公开。 必填项已用*标注