PHP code example of laoshifu / think-cache

1. Go to this page and download the library: Download laoshifu/think-cache library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laoshifu / think-cache example snippets


use laoshifu\cache\facade\Cache;

// 设置缓存
Cache::set('name', 'value', 3600);

// 获取缓存
$value = Cache::get('name');

// 删除缓存
Cache::delete('name');

// 清空缓存
Cache::clear();

return [
    'default' => 'file',
    'stores' => [
        'file' => [
            'type' => 'File',
            'path' => runtime_path('cache'),
        ],
        'redis' => [
            'type' => 'Redis',
            'host' => '127.0.0.1',
            'port' => 6379,
            'password' => '',
            'select' => 0,
            'timeout' => 0,
        ],
    ],
];