承接 jrsaunders/quickasync 相关项目开发

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

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

jrsaunders/quickasync

Composer 安装命令:

composer require jrsaunders/quickasync

包简介

Async Processess

README 文档

README

Quick Async Process Library

Latest Stable Version Total Downloads Latest Unstable Version License

Install via composer

$composer require jrsaunders/quickasync

Setup

Put this in an index or core class. This will tell your Application where to store its async processes.

<?php
use QuickAsync\Setup;

Setup::setBasePath( '/var/www/vhost/some/dir/async' );

Cron Job to Process Async Jobs

<?php

$multiProcess = new \QuickAsync\MultiProcess(BASEPATH . '../cron.php /async/run/%%file%%');
$sleepBetweenCollections = 1;
$killMultiProcessCollectionsAfterSeconds = 60;
$multiProcess->process($sleepBetweenCollections, $killMultiProcessCollectionsAfterSeconds);

Async Job Process

<?php

class Async extends MyApp {
	public function run( $asyncFile = null ) {
		if ( isset( $asyncFile ) ) {
			$queueItem = new \QuickAsync\QueueItem( $asyncFile );
			$asyncData = $queueItem->getObject();
		    $queueItem->run( $this );
		}
	}


}

Simple Use

<?php
use QuickAsync\Item;

class CoolClass extends MyApp(){

  public function somethingCool($name,$carName){
      
      //save this car to my name or something like that do some complicated processing.....
      return $importantData;
  }
  
  public function triggerAsyncProcess(){
      $asyncItem = new Item($this,'CoolClass','somethingCool',['John','Lamborghini'],__FILE__);
      asyncItem->queue();
  
  }


}


Use with QuickCache

https://github.com/JRSaunders/QuickCache get setup instructions for QuickCache from here.

<?php
use QuickAsync\Item;
use QuickAsync\AsyncCache;
use QuickCache\Cache;

class CoolClass extends MyApp(){

  public function somethingCool($name,$carName){
      
      //save this car to my name or something like that do some complicated processing.....
       return $importantData;
  }
  
  public function getData(){
  
      $cacheName = md5('MyUniqueName');
      $ttl = 120;//120 seconds
      $cache = new Cache();
      $cachedData = $cache->getCacheData( $cacheName, $ttl );
      
      //if there is no cache data go get some from an extenral process and then wait for the result and pick it up.
      //if it takes to long do something else. but job carries on none the less in the background.
      
      if(!cachedData){
        $asyncItem = new Item($this,'CoolClass','somethingCool',['John','Lamborghini'],__FILE__);
        $asyncCache = new AsyncCache(
          $this,
          $cacheName,
          $cacheName,
          $ttl,
          $asyncItem,
          $cache,
          1,
          false,
          $catchCacheTimeout,
          function ( $t ) {
            if ( $t > 20 ) {
              if ( ! defined( 'RUNNINGFROMCRON' ) ) {
                header( 'Location: /admin/dashboard?flash=' .
                        urlencode( 'Try back in a minute your car is currently building! <a href="' . $_SERVER['REQUEST_URI'] . '"> Try back </a>' )
                );
                exit();
              }
            }

          }
        );

        $cachedData = $asyncCache->getData();
      }
      
      return $cachedData;
  
  }


}


统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2017-06-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固