esemve/vanillacache 问题修复 & 功能扩展

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

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

esemve/vanillacache

Composer 安装命令:

composer require esemve/vanillacache

包简介

Powerful cache engine for Laravel 5

README 文档

README

Vanilla Cache is a Cache System for Laravel 5.X. It's a response cache system, so you can cache the full html response, and serve this next time without booting Laravel.

You can use this in shared webserver. The request time is max 10-20ms with this cache.

It's a dev version! Please don't use this in live project!

Installation

composer require esemve/vanillacache –dev

Add to providers:

Esemve\VanillaCache\CacheServiceProvider::class

Add to Facades:

'Vanilla' => Esemve\VanillaCache\Facades\Vanilla::class

After:

composer dump-autoload
php artisan vendor:publish

You can create a cache from Laravel now!

Next step is to set up the CacheServer. It will serve cache BEFORE laravel has loaded. Add to your composer.json "autoload" section beginning:

"files": ["config/vanilla.php","vendor/esemve/vanillacache/vanilla/CacheServer.php"],

Why is the config/vanilla.php is so weird?

Because it is loading BEFORE Laravel, so you can't use any Laravel specified function in this file!

How to use?

use \Vanilla;
…

  public function index(RoomRepository $roomRepository)
    {
        $rooms = $roomRepository->getAll();

        return Vanilla::Cache(View::make('cinema.index',[
            'rooms' => $rooms
        ]),10);
    }

Vanilla::Cache($view,$sec)

Saves the view content for the actual url (include GET parameters) for 10 sec. If less than in 10 sec any user open this url, the CacheServer will serve the cache without booting Laravel.

Engines

VanillaCache contains a file engine default. You can create an engine (for example: mysql, redis etc).

How can you create an engine?

config/vanilla.php

'file' => [
	    'laravel' => 'Esemve\\VanillaCache\\Engines\\FileEngine',
	    'vanilla' => __DIR__.'/../vendor/esemve/vanillacache/vanilla/Engines/FileEngine.php',
	    'config' => [
		'storage_folder' => realpath(__DIR__.'/../storage/').'/vanilla/'
	    ]
	]

„file”: name of engine

In „laravel” => 'xxx' section fills a namespace for your cache engine. The Esemve\VanillaCache\Engines\Engine interface must be implemented. This engine is live IN Laravel

In „vanilla” => 'xxx' section can set up the engine file what loading BEFORE laravel. It must implement Esemve\VanillaCache\Interfaces\EngineInterface. It will serve the cache content to CacheServer.

The „config” section will send to your engine.

Dinamic content / blocks (Similar SSI)

All page contains dynamic or repeted elements, for example right side, menus etc. From this elements you can generate a HTML, and you can include it to your cache.

Generate a HTML for cache:

Vanilla::storeHtml(„rightSide”,view(„_partials.rightSide”))

After this you can use a <##html:##> tag in your page.

<html>
...
<body><!--
<##html:rightSide##>
-->
...
</body>
</html>

The CacheServer AND the Laravel will automatice replace this tag (with comment tags if that exists) to the stored html content.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固