承接 juhara/zzzmiddleware 相关项目开发

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

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

juhara/zzzmiddleware

Composer 安装命令:

composer require juhara/zzzmiddleware

包简介

A cache middleware for Slim Framework (3.0) using ZzzCache

README 文档

README

Cache middleware for Slim Framework 3.0 using ZzzCache

Requirement

Installation

Run through composer

$ composer require juhara/zzzmiddleware

How to use

Register CacheMiddleware to Slim Dependency Container

<?php
...
use Juhara\ZzzCache\Contracts\CacheInterface;
use Juhara\ZzzCache\Cache;
use Juhara\ZzzCache\Storages\File;
use Juhara\ZzzCache\Helpers\ExpiryCalculator;
use Juhara\ZzzCache\Helpers\Md5Hash;

$container[CacheInterface::class] = function ($c) {
    // create a file-based cache where all cache
    // files is stored in directory name
    // app/storages/cache with
    // filename prefixed with string 'cache'
    return new Cache(
        new File(
            new Md5Hash(),
            'app/storages/cache/',
            'cache'
        ),
        new ExpiryCalculator()
    );
};

use Juhara\CacheMiddleware\CacheMidleware;
use Juhara\CacheMiddleware\ResponseCacheFactory;

$container[CacheMiddleware::class] = function ($c) {
    $cache = $c->get(CacheInterface::class);
    $factory = new ResponseCacheFactory();
    return new CacheMiddleware($cache, $factory);
};

Add CacheMiddleware to Slim Application

use Slim\App;
use  Juhara\CacheMiddleware\CacheMiddleware;

$app = new App($settings);
...
$app->add(CacheMiddleware::class);

Create Proper Configuration

If using Juhara\ZzzCache\Storages\File as storage, then you need to make sure that directory of cache is writeable by web server.

Example

See example application to understand how to use CacheMiddleware.

Contributing

Just create PR if you want to improve it.

Thank you.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2018-04-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固