承接 titasgailius/closure-cache 相关项目开发

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

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

titasgailius/closure-cache

Composer 安装命令:

composer require titasgailius/closure-cache

包简介

Cache method, function or closure results.

README 文档

README

A simple PHP cache mechanism for storing method, function or closure results.
It calculates result of the closure once and returns it on subsequent calls.

Usage

<?php

function somethingSlow()
{
    return once(function () {
        // Code...
    });
}

Installation

With composer

$ composer require titasgailius/closure-cache
{
    "require": {
        "titasgailius/closure-cache": "~1.00"
    }
}

Example

Before

<?php

class SomeClass
{
    public static function think()
    {
        sleep(10);

        return 'It takes some time to process this.';
    }
}

/**
 * 10 seconds to process it.
 */
SomeClass::think();

/**
 * Another 10 seconds to process it
 * which makes it 20 seconds in total.
 */
SomeClass::think();

After

<?php

class SomeClass
{
    public static function think()
    {
        return once(function () {
            sleep(10);

            return 'It takes some time to process this.';
        });
    }
}

/**
 * 10 seconds to process
 */
SomeClass::think();

/**
 * ClosureCache detects that this was already
 * processed and returns it from the cache.
 */
SomeClass::think();

ClosureCache is parameter-sensitive

<?php

class SomeClass
{
    public static function think($message)
    {
        return once(function () use ($message) {
            sleep(10);

            return $message;
        });
    }
}

/**
 * 10 seconds to process
 */
SomeClass::think('foo');

/**
 * Another 10 seconds to process it because
 * different parameters were passed.
 */
SomeClass::think('bar');

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固