承接 nocs/laravel-retriever 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

nocs/laravel-retriever

最新稳定版本:v1.1.9

Composer 安装命令:

composer require nocs/laravel-retriever

包简介

Retrieve cached data made simple.

README 文档

README

Latest Version on Packagist Total Downloads

Retrieve cached data made simple

Installation

Install with composer

composer require nocs/laravel-retriever

Usage

Place your cache files under app/Retrievers (primary) or app/Cache (secondary).

Use the App\Retrievers or App\Cache namespace for your classes.

Use, as usual, studlied strings for your classnames. When retrieving use a snaked version in your key.

Define public non-static methods which return the cached values.

Basic usage

Example: app/Cache/Colors.php

<?php

namespace Nocs\Retriever\Tests\Cache;

class Colors {

    public function red()
    {
        return 'red';
    }

}

Retrieve the value with:

<?php

$value = retriever()->get('colors.red');

Using one method

When using only one method, you can use the get method. app/Cache/Colors.php

<?php

namespace Nocs\Retriever\Tests\Cache;

class Colors {

    public function get()
    {
        return 'red';
    }

}

And retrieve the value with:

<?php

$value = retriever()->get('colors');

Using namespaces

When creating vendors you can use namespaces.

Give your cache files the correct namespace, for example MyVendor\Cache.

Place your cache class files in location src/Retrievers or src/Cache.

Add the location in your ServiceProvider class in the boot section.

<?php

namespace Vendor\Package\Providers;

use Illuminate\Support\ServiceProvider;
use Nocs\Retriever\Support\Facades\Retriever;

class PackageServiceProvider extends ServiceProvider
{

    public function boot(Router $router)
    {

        Retriever::loadRetrieversFrom(__dir__.'/../Cache', 'package');

    }
}

Retrieve the value with the namespace prefixed (snaked) to the key:

<?php

$value = retriever()->get('my_vendor::colors');

Arguments

A second argument to the get call can be provided as an array of arguments that will be passed to the cache closure.

Short

Instead of using

<?php

$value = retriever()->get('key');
$value = retriever()->get('key', 'default');

you can use

<?php

$value = retriever('key', 'default');

Testing

To test, run

composer test

Security

If you discover any security related issues, please email the author instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固