fmihel/php-cache 问题修复 & 功能扩展

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

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

fmihel/php-cache

Composer 安装命令:

composer require fmihel/php-cache

包简介

php,cache

README 文档

README

simple cache for php functions result

Install

composer require fmihel/php-cache

Example

<?php

require_once __DIR__ . '/vendor/autoload.php';
use fmihel\cache\Cache;
use fmihel\cache\drivers\FileCacheDriver;

const KEY_1 = 'key_1';

class MyClass{

    static function strong($count1 = 10000,$count2 = 10000){
        sleep(1);  
        $out = 0;
        for($i=0;$i<$count1;$i++){
            for($j=0;$j<$count2;$j++){
                $out++;
            };
        };
        return $out;
    }

    static function cached_strong($count1 = 10000,$count2 = 10000){
        global $cache;
        return $cache->get(KEY_1,func_get_args(),function() use($count1,$count2){
            
            return self::strong($count1,$count2);

        });
    }
};


$cache = new Cache(new FileCacheDriver(/*path*/));// default story cache to $_SERVER['PWD'].'/cache';

$get = MyClass::cached_strong(1000000,100000);


?>

class Cache

name params note
get(string $key,array $params,$callback,$lifetime):any $key - unique key
$params - array of input params
$callback - wrap function for caching method
$lifetime - period in hours
caching function result
clear() clear cache
setDriver(iCacheDriver $driver) $driver - cache engine driver, implements iCacheDriver interface set cache driver,
exists SimpleCacheDriver,FileCacheDriver,SerCacheDriver
enable(bool=null) bool - if boolean set enable/disable caching, or return curent set if bool===null
clearOld() removes outdated caches

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固