定制 andydune/object-cache-proxy 二次开发

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

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

andydune/object-cache-proxy

Composer 安装命令:

composer require andydune/object-cache-proxy

包简介

Allow cache results for execution object method. Transparent to working code.

关键字:

README 文档

README

Build Status Software License Packagist Version Total Downloads

Allow cache results for execution object method. Transparent to working code.

Installation

Installation with composer:

composer require andydune/object-cache-proxy

Or if composer didn't install globally:

php composer.phar require andydune/object-cache-proxy

Or edit your composer.json:

"require" : {
     "andydune/object-cache-proxy": "^1"
}

And execute command:

php composer.phar update

Problem

Here is instance of any class. We use setters for inject data and finally execute the last method for retrieve data. We do it often with narrow range of input data. How can we simple to change it for speedup?

$instance = new Adventures(); // any class

// Use some setters 
$instance->setDirection('up');
$instance->setSpeed('low');
$instance->setLimit(13);

// Next is results
$ways = $instance->get(); 

We can use ObjectCacheProxy to cache it with minimum work code change.

use AndyDune\ObjectCacheProxy\ObjectCacheProxy;
use Symfony\Component\Cache\Simple\FilesystemCache;

$instanceOrigin = new \Adventures(); // any class

$instance = new ObjectCacheProxy(new FilesystemCache());

// inject object and method name witch results will be cached. 
$instance->setObject($instanceOrigin, 'get');

// Use some setters 
$instance->setDirection('up');
$instance->setSpeed('low');
$instance->setLimit(13);

// Next is results
$ways = $instance->get(); 

ObjectCacheProxy gets work class instance and intercept methods are called to it. It accumulates setter methods and parameters as cache key and executes them at ones before execution method get.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-05-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固