The other problem I had with Laravel Task Scheduling was that i really only wanted something to handle the scheduling. I already had my logical unit of work defined the task that needed to be completed and I didn’t want to have to rebuild it. Thankfully, that is all that cron-expression brings to the table. It literally takes a string that is the first 5 arguments of a cron task and parses them. it will tell you if it’s due to run, it will tell you when it will run next and when it ran last.

Most of the solutions I threw out, I did so because they were either unmaintained or they did too much. cron-expression is a discrete piece of code that does a single test.

Really, the only problem I ran into was the almost nonexistent documentation. The Readme on the project gives you the basics but the examples are pretty simple and not always useful. Thankfully, Michael Dowling, the author, wrote a great article about WHY he built it and also shows a lot of examples on HOW to use it. If you are going to use this code, make sure you read “Cron Expression Parsing in PHP” . Not only is Michael a good writer, it is very informative.

:Conclusion

If you are looking for “Do this at that time” there are a lot of PHP based solutions available for you. If you are early enough in your design process to make framework choices, look seriously at the larval solution, although there are others that are framework agnostic also.

Side Note

I ad spent countless hours trying to create the solution myself. Since everything I was working with will be inside a MySQL database, I envisioned a convoluted and ultimately beautiful SQL statement that would do all of the calculations for me and tell me exactly when something was to run. I got so lost in solving the problem, I forgot to look to see if someone had already solved it.

Repeat after me. My idea is not a snowflake, someone else has done it.

USE THE SOURCE!

This was more for me than you.

― Cal Evans (@CalEvans) November 16, 2016

根据pathinfo访问对应得controller,如ip:port/home/index/index则会访问home目录下的IndexController的index方法;如果不指定pathinfo则访问home目录下的IndexController的index方法

service service层: $sql = 'select * from admin_user where id=1'; $data['sql'] = $sql; $data['info'] = yield table('admin_user')->where(['id'=>1])->find(); return $data; controller层: //使用1-封装在service层,controller层也得写yield $testservice = new TestService(); $data = yield $testservice->test(); return $data; Cache-redis(已经是异步非阻塞)

配置:

return [ 'redis'=>[ 'ip' => 'localhost', 'port' => 6379, 'select' => 0, 'password' => '', 'asyn_max_count' => 10, ] ];

使用:

$data = yield Db::redis()->cache('abcd');

只要在config目录下配置cache文件,即可在业务里调用缓存方法,如:

数据库 mysql(已经是异步非阻塞)

在config下配置mysql的配置文件,即可在业务中使用,你可以使用以下方法查询数据

$data = yield Db::table()->query('select* from admin_user'); $a = yield DB::table()->query('select*from admin_user where id =1'); $userinfo = yield table('admin_user')->where(['id'=>1])->find(); http client(已经是异步非阻塞) $httpClient = new HttpClientCoroutine(); $data = yield $httpClient->request('http://speak.test.com/'); 框架全部封装好.怎么样,这异步用起来是不是很简单^_^ mongo(还是同步阻塞的)

Swoole + zphp 改造为专门用来开发接口的框架的更多相关文章

  1. Android JNI 本地开发接口

    前言 我们为什么要用JNI --> 高效.扩展 高效:Native code效率高,数学运算,实时渲染的游戏上,音视频处理 (极品飞车,opengl,ffmpeg,文件压缩,图片处理-) 扩展: ...

  2. C#.NET 大型通用信息化系统集成快速开发平台 4.0 版本 - 多系统开发接口 - 苹果客户端开发接口

    最近工作上需要,给苹果客户端开发接口,实现集中统一的用户管理,下面是接口调用参考. 1: 获取OpenId? http://127.0.0.1/GetOpenId.ashx?username=Admi ...

  3. 准备.Net转前端开发-WPF界面框架那些事,值得珍藏的8个问题

    题外话 不出意外,本片内容应该是最后一篇关于.Net技术的博客,做.Net的伙伴们忽喷忽喷..Net挺好的,微软最近在跨平台方面搞的水深火热,更新也比较频繁,而且博客园的很多大牛也写的有跨平台相关技术 ...

  4. 关于web开发前端h5框架的选择

    关于web开发前端h5框架的选择 看了很多移动版框架都是基于app混合式开发的,不是单独h5网站的基于h5开发的web框架从组件丰富度,兼容性,相关教程来说bootstrap还是最好的react和vu ...

  5. iOS 开发之照片框架详解(2)

    一. 概况 本文接着 iOS 开发之照片框架详解,侧重介绍在前文中简单介绍过的 PhotoKit 及其与 ALAssetLibrary 的差异,以及如何基于 PhotoKit 与 AlAssetLib ...

  6. HIbernate学习笔记(二) hibernate对象的三种状态与核心开发接口

    1.在hibernate中持久化对象有三个状态,这个面试时可能会问到: (1)transient瞬时态:在数据库中没有与之匹配的数据,一般就是只new出了这个对象,并且在session缓存中也没有即此 ...

  7. NET Core开发-使用Nancy框架

    NET Core开发-使用Nancy框架 Nancy简介 Nancy是一个轻量级的独立的框架,下面是官网的一些介绍: Nancy 是一个轻量级用于构建基于 HTTP 的 Web 服务,基于 .NET ...

  8. iOS 开发之照片框架详解之二 —— PhotoKit 详解(下)

    本文链接:http://kayosite.com/ios-development-and-detail-of-photo-framework-part-three.html 这里接着前文<iOS ...

  9. iOS 开发之照片框架详解

    转载自:http://kayosite.com/ios-development-and-detail-of-photo-framework.html 一. 概要 在 iOS 设备中,照片和视频是相当重 ...

随机推荐

  1. MEF 松耦合

    MEF天生就有解耦合的特性,虽然它不是为解耦而生,而主要是为插件类应用的开发而设计.如果主要是为了解除耦合的话可以使用IoC,Unity等. Unity 微软的IOC 代码: using System ...

  2. .NET Framework Execution Was Aborted By Escalation Policy

    错误#1 09:31 2015/1/26上班查看ERRORLOG发现下面错误信息字面上理解是有内存压力,中午的时候ERRORLOG频繁报下面错误问题核实,一台服务器上安装两个实例,其中一个实例设置了最 ...

  3. JavaScript学习笔记之BOM

    BOM的核心对象是window,它既表示浏览器窗口以及页面可见区域,同时也是ECMAScript中的Globe对象,所有的全局变量和函数都是它的属性,并且所有的原声函数以及其他函数也都存在于它的命名空 ...

  4. bootstrap学习之三—插件

    一.模态框(modal)插件 1)为要触发模态框的组件添加data-toggle="modal",data-target="对应ID" 2)使用一个div实现m ...

  5. RPC、SQL、NFS属于OSI的哪一层

    第一层:物理层 第二层:数据链路层 802.2.802.3ATM.HDLC.FRAME RELAY 第三层:网络层 IP.IPX.ARP.APPLETALK.ICMP 第四层:传输层 TCP.UDP. ...

  6. Fiddler 的Window 8.1中不可以正常工作

    昨天晚上新升级了操作系统至Windows 8.1 Pro,发现使用Fiddler时网站不能正常使用,导致“代理错误”等信息. 解决方案: http://fiddler2.com/blog/blog/2 ...

  7. Highcharts选项配置详细说明文档(zz)

    http://www.helloweba.com/view-blog-156.html Highcharts提供大量的选项配置参数,您可以轻松定制符合用户要求的图表,目前官网只提供英文版的开发配置说明 ...

  8. respondsToSelector: selector

    -(BOOL) respondsToSelector: selector 用来判断是否有以某个名字命名的方法(被封装在一个selector的对象里传递)

  9. Ini文件操作函数

    /// <summary> /// Copies a string into the specified section of an initialization file. /// &l ...

  10. extjs grid 单元格 多选

    new Ext.grid.CellSelectionModel({ last : false, // 上一次选中的单元格 selections : [], // 选择区缓存 handleMouseDo ...