unrulynatives/laravel-configurable-cache 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

unrulynatives/laravel-configurable-cache

最新稳定版本:v1.0.1

Composer 安装命令:

composer require unrulynatives/laravel-configurable-cache

包简介

Configurable Laravel cache manager

README 文档

README

Laravel Configurable Cache: Laravel 12

Latest Version on Packagist Total Downloads GitHub Actions GitHub Actions codecov PHPStan PHP Version Require

Header Image

Features

  • Provides configurable cache settings with dedicated ttl and prefix for each
  • Supports all main cache operations provided by Laravel, such as put, get, increment, and delete

Requirements

  • PHP: ^8.1
  • Laravel framework: ^9
Version L9 L10 L11
1.4

Installation

You can install the package via composer:

composer require salehhashemi/laravel-configurable-cache

Next, from the command line type:

php artisan vendor:publish --provider="Salehhashemi\ConfigurableCache\ConfigurableCacheServiceProvider"

Finally, adjust the settings in the published configuration file located in config/configurable-cache.php as per your requirements.

Usage

To use the package, you can use the ConfigurableCache class methods. Here's an example:

use Salehhashemi\ConfigurableCache\ConfigurableCache;
    
// Storing an item in the cache with `_tiny_` prefix for 15 minutes
ConfigurableCache::put('testKey', 'Hello World!', 'tiny');
    
// Retrieving an item from the cache with `_short_` prefix that is stored for an hour
$value = ConfigurableCache::get('testKey', 'short');

// Delete a cache item with `_otp_` prefix
ConfigurableCache::delete('testKey', 'otp');

// if `testKey` doesn't exist in the 'default' cache, the Closure will be executed and its result will be stored in the cache under `testKey` with `_default_` prefix
$value = ConfigurableCache::remember('testKey', function () {
    return 'Hello World!';
});

Default configuration

You can change these configurations in your configurable-cache.php config file:

'configs' => [
    'default' => [
        'prefix' => '_default_',
        'duration' => '+1 Year',
    ],
    'tiny' => [
        'prefix' => '_tiny_',
        'duration' => '+15 minutes',
    ],
    'short' => [
        'prefix' => '_short_',
        'duration' => '+1 hour',
    ],
    'otp' => [
        'prefix' => '_otp_',
        'duration' => '+3 minutes',
    ],
]

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固