定制 leafs/cache 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

leafs/cache

最新稳定版本:v0.1.0

Composer 安装命令:

composer require leafs/cache

包简介

Leaf PHP cache module

README 文档

README





Leaf Cache

Cache module for Leaf.

leaf install cache

Or with composer:

composer require leafs/cache

Usage

You can use the cache module to store data, usually to avoid repeated expensive operations.

Cache data forever:

$value = cache(
    'key',
    function() {
        // expensive operation
        return 'value';
    },
);

Cache data for a specific time (in seconds):

$value = cache(
    'key',
    600, // 10 minutes
    function() {
        // expensive operation
        return 'value';
    },
);

Unlike other frameworks, the cache function will always return the cached value if it exists, meaning that the closure will only be executed if the cache key does not exist. So you don't need to check if the value exists before calling the cache function.

Extended Usage

The cache module is built on top of the Illuminate Cache component, so you can use all the features of that component. To do that, you can call the cache() function without any parameters to get the cache repository instance:

cache()->put('key', 'value', 600); // cache for 10 minutes
$value = cache()->get('key');

For most use cases, the cache() function is sufficient, but if you need more control, you can use the cache repository instance directly.

You can use this to manually overwrite a cache key:

// will not set the cache if it already exists
cache('key', 600, 'new value'); // cache for 10 minutes

// will always set the cache, even if it already exists
cache()->put('key', 'new value', 600); // cache for 10 minutes

统计信息

  • 总下载量: 167
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固