laoshifu/think-cache

ThinkPHP 8.0 缓存扩展包

Maintainers

Package info

github.com/laoshifu-tech/think-cache

pkg:composer/laoshifu/think-cache

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2025-12-08 03:29 UTC

This package is auto-updated.

Last update: 2026-03-08 04:01:07 UTC


README

适用于 ThinkPHP 8.0+ 的缓存扩展包。

安装

composer require laoshifu/think-cache

支持的驱动

  • File(文件缓存)
  • Redis
  • Memcache
  • Memcached
  • Wincache

使用方法

use laoshifu\cache\facade\Cache;

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

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

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

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

配置

config/cache.php 中配置:

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,
        ],
    ],
];

版权信息

Copyright © 2025 贵州老师傅到家科技有限公司

Licensed under the Apache License 2.0