定制 genesis/method-persister 二次开发

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

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

genesis/method-persister

Composer 安装命令:

composer require genesis/method-persister

包简介

Allows caching of any method in code.

README 文档

README

What is this?

This library allows caching the result of methods for a specified amount of time. This can be on a global level or per user session.

Installation

Using composer:

composer require "genesis/method-persister"

Instantiation

namespace ABC\Example;

use Genesis\MethodPersister;

// Ideally done using a DI library.
$centralStoragePath = '/tmp/cache/';
$persistenceRepository = new MethodPersister\PersistenceRepository($centralStoragePath);
$persister = new MethodPersister\Persister($persistenceRepository);

Usage

Consider your code like this:

$result = $myObject->myMethod($arg1, $arg2);

return $result;

The above can be rewritten with the cacher as follows yielding the same but faster results.

$result = $persister->persist($myObject, 'myMethod')
	->withParameters($arg1, $arg2)
	->overAPeriodOf('+10 seconds')
	->execute();

// Use result as normal
return $result;

This will persist the cache for 10 seconds from the first call, after that the cache will be refreshed. The default storage method is centralised but can be changed to distributed i.e session caching using the ->in() method.

$result = $persister->persist($myObject, 'userSpecificData')
    ->withParameters($arg1, $arg2)
    ->overAPeriodOf('+10 seconds')
    ->in(PersisterInterface::STATE_DISTRIBUTE)
    ->execute();

Contributions

This project is in its early stages, forks are welcome :)

Tests

Library is tested using phpunit. To run tests first install dependencies using composer then run command:

make

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固