定制 shaneen31/russian-doll-caching 二次开发

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

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

shaneen31/russian-doll-caching

Composer 安装命令:

composer require shaneen31/russian-doll-caching

包简介

description_text

README 文档

README

Version 0.2.0

Main Features

  • Allow caching fragment of pages.
  • Cache single objects.
  • Cache one big object made of smaller ones (Cascade Caching).
  • Cache on disk.
  • Cache with Redis.

How To Use

Cache using disk

Example to cache posts with Laravel.

Cache single object

In your view

<?php
use RussianDollCaching\Cache;
use RussianDollCaching\DiskCache;

$cache = new Cache(new DiskCache());
?>
<?php foreach($posts->get() as $post): ?>
    <?php $cache->cache($post, function() use ($post){ ?>
        some code
    <?php }); ?>
<?php endforeach; ?>

Cascade Caching

In your model

public static function lastUpdated(){
        return self::orderBy('updated_at', 'DESC')->select('id', 'updated_at')->first();
    }
    

In your view

<?php
use RussianDollCaching\Cache;
use RussianDollCaching\DiskCache;

$cache = new Cache(new DiskCache());
?>

<?php $cache->cache(['posts', \App\Post::lastUpdated()], function() use ($cache, $posts){   ?>
    <?php foreach($posts->get() as $post): ?>
        <?php $cache->cache($post, function() use ($post){ ?>
            some code
        <?php }); ?>
    <?php endforeach; ?>
<?php }); ?>

Cache using redis

Example to cache posts with Laravel.

Cache single object

In your view

<?php
use RussianDollCaching\Cache;
use RussianDollCaching\RedisCache;

$cache = new Cache(new RedisCache());
?>
<?php foreach($posts->get() as $post): ?>
    <?php $cache->cache($post, function() use ($post){ ?>
        some code
    <?php }); ?>
<?php endforeach; ?>

Cascade Caching

In your model

public static function lastUpdated(){
        return self::orderBy('updated_at', 'DEST')->select('id', 'updated_at')->first();
    }
    

In your view

<?php
use RussianDollCaching\Cache;
use RussianDollCaching\RedisCache;

$cache = new Cache(new RedisCache());
?>
<?php $cache->cache(['posts', \App\Post::lastUpdated()], function() use ($cache, $posts){   ?>
    <?php foreach($posts->get() as $post): ?>
        <?php $cache->cache($post, function() use ($post){ ?>
            some code
        <?php }); ?>
    <?php endforeach; ?>
<?php }); ?>

License

The code for RussianDollCaching is distributed under the terms of the GNU/GPL V3 license (see LICENSE).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2016-03-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固