PHP C++ 混合编程 paozhu 框架 1.5.6 发布,自带 URL 拦截
大量历史遗留PHP代码,公司要数据大屏,数据分析PHP难以胜任,现在paozhu框架可以满足你的需求。paozhu C++框架自带httpserver 支持http1 http2 通过拦截URL,达到PHP C++混合编程。
paozhu可以做PHP 前端,代替apache nginx,通过url拦截,区分走c++还是php.
paozhu 1.5.6 大量更新了ORM 代码
1 添加对,FrameworkBenchmarks 框架评测支持,下一轮可以看到paozhu排名。
paozhu 经历上百万压力测试,各种压力测试都可以稳定应付,没有崩溃退出,没有内存飙升。
2 ORM添加 fetch_one和soft_remove 和几个where条件,官方教程马上会推出来。
fetch_one 只取一条数据
soft_remove 软删除,并非真正删除,而是标记数据表deleted 字段
3 修改了责任链方法,将来流程管理可以使用上。
经典FrameworkBenchmarks代码,paozhu可以轻松对应
#include "orm.h" #include <chrono> #include <thread> #include "httppeer.h" #include "techempower.h" #include "techempower_json.h" #include "datetime.h" #include "func.h" #include "pzcache.h" #include "json_reflect_headers.h" namespace http { //@urlpath(null,plaintext) std::string techempowerplaintext(std::shared_ptr<httppeer> peer) { peer->type("text/plain; charset=UTF-8"); peer->set_header("Date", get_gmttime()); peer->output = "Hello, World!"; return ""; } //@urlpath(null,json) std::string techempowerjson(std::shared_ptr<httppeer> peer) { peer->type("application/json; charset=UTF-8"); peer->set_header("Date", get_gmttime()); struct techempower_outjson_t a; a.message = "Hello, World!"; peer->output = json_encode(a); return ""; } //@urlpath(null,db) std::string techempowerdb(std::shared_ptr<httppeer> peer) { peer->type("application/json; charset=UTF-8"); peer->set_header("Date", get_gmttime()); auto myworld = orm::World(); unsigned int rd_num = rand_range(1, 10000); myworld.get_one(rd_num); peer->output = myworld.data_tojson(); return ""; } //@urlpath(null,queries) std::string techempowerqueries(std::shared_ptr<httppeer> peer) { peer->type("application/json; charset=UTF-8"); peer->set_header("Date", get_gmttime()); unsigned int get_num = peer->get["queries"].to_int(); if (get_num == 0) { get_num = 1; } else if (get_num > 500) { get_num = 500; } auto myworld = orm::World(); for (unsigned int i = 0; i < get_num; i++) { myworld.wheresql.clear(); unsigned int rd_num = rand_range(1, 10000); myworld.where("id", rd_num).fetch_append(); } peer->output = myworld.to_json(); return ""; } //@urlpath(null,fortunes) std::string techempowerfortunes(std::shared_ptr<httppeer> peer) { peer->type("text/html; charset=UTF-8"); peer->set_header("Date", get_gmttime()); auto myfortune = orm::Fortune(); myfortune.fetch(); myfortune.data.id = 0; myfortune.data.message = "Additional fortune added at request time."; myfortune.record.push_back(myfortune.data); std::sort(myfortune.record.begin(), myfortune.record.end(), [](const auto &lhs, const auto &rhs) { return lhs.message < rhs.message; }); peer->val["list"].set_array(); OBJ_ARRAY item; for (unsigned int i = 0; i < myfortune.record.size(); i++) { item["id"] = myfortune.record[i].id; item["message"] = html_encode(myfortune.record[i].message); peer->val["list"].push(item); } peer->view("techempower/fortunes"); return ""; } //@urlpath(null,updates) std::string techempowerupdates(std::shared_ptr<httppeer> peer) { peer->type("application/json; charset=UTF-8"); peer->set_header("Date", get_gmttime()); unsigned int get_num = peer->get["queries"].to_int(); if (get_num == 0) { get_num = 1; } else if (get_num > 500) { get_num = 500; } auto myworld = orm::World(); myworld.record.clear(); for (unsigned int i = 0; i < get_num; i++) { myworld.wheresql.clear(); unsigned int tempid = rand_range(1, 10000); myworld.where("id", tempid).fetch_append(); if (myworld.effect() > 0) { unsigned int j = myworld.record.size() - 1; myworld.data.randomnumber = rand_range(1, 10000); myworld.record[j].randomnumber = myworld.data.randomnumber; myworld.update("randomnumber"); } } peer->output = myworld.to_json(); return ""; } //@urlpath(null,cached-queries) std::string techempowercached_queries(std::shared_ptr<httppeer> peer) { peer->type("application/json; charset=UTF-8"); peer->set_header("Date", get_gmttime()); unsigned int get_num = peer->get["count"].to_int(); if (get_num == 0) { get_num = 1; } else if (get_num > 500) { get_num = 500; } auto myworld = orm::World(); std::string mycacheid = "alldatacache"; pzcache<std::vector<orm::worldbase::meta>> &temp_cache = pzcache<std::vector<orm::worldbase::meta>>::conn(); std::vector<orm::worldbase::meta> allcachedata_array; //create rand data to cache if (temp_cache.check(mycacheid) > -1) { allcachedata_array = temp_cache.get(mycacheid); } else { allcachedata_array.resize(10000); for (unsigned int i = 0; i < 10000; i++) { allcachedata_array[i].id = i + 1; allcachedata_array[i].randomnumber = rand_range(1, 10000); } temp_cache.save(mycacheid, allcachedata_array, 120); } //get rand data from cache mycacheid = "my" + std::to_string(get_num); if (temp_cache.check(mycacheid) > -1) { myworld.record = temp_cache.get(mycacheid); } else { if (allcachedata_array.size() == 10000) { for (unsigned int i = 0; i < get_num; i++) { unsigned int temp_rid = rand_range(0, 9999); myworld.record.push_back(allcachedata_array[temp_rid]); } } temp_cache.save(mycacheid, myworld.record, 120); } peer->output = myworld.to_json(); return ""; } //@urlpath(null,cached-db) std::string techempowercached_db(std::shared_ptr<httppeer> peer) { peer->type("application/json; charset=UTF-8"); peer->set_header("Date", get_gmttime()); //this test from database to cache unsigned int get_num = peer->get["count"].to_int(); if (get_num == 0) { get_num = 1; } else if (get_num > 500) { get_num = 500; } auto myworld = orm::World(); std::string mycacheid = "my" + std::to_string(get_num); pzcache<std::vector<orm::worldbase::meta>> &temp_cache = pzcache<std::vector<orm::worldbase::meta>>::conn(); if (temp_cache.check(mycacheid) > -1) { myworld.record = temp_cache.get(mycacheid); } else { std::vector<unsigned int> cacheid; for (unsigned int i = 0; i < get_num; i++) { cacheid.push_back(rand_range(1, 10000)); } std::string sqlstr = array_to_sql(cacheid); myworld.whereIn("id", sqlstr).fetch(); temp_cache.save(mycacheid, myworld.record, 120); } peer->output = myworld.to_json(); return ""; } }// namespace http

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
LiteFlow v2.11.4 正式版本发布!一个越来越强大的规则引擎
前言 2.11.4经历了BETA1,BETA2,BETA3版本之后,正式版发布! 2.11.4总共有18个issue的更新,绝大多数为增强类issue。在这个版本中,我们优化了底层,着重优化了性能。也提供了一些小特性的升级。 强烈建议还在用2.11.3版本的同学进行升级。 接下来挑几个更新的增强来详细说下。 重写了声明式的部分 此增强issue困扰我半个多月,一直以来,LiteFlow声明式的底层代码比较混乱。不太好阅读,而且始终会在一些边缘场景莫名其妙的出问题。我一直想对其进行重写,这个版本,我阅读了大量了spring bean构造的底层代码,终于在底层实现了更加优化的改造。改造之后的声明式底层代码更加合理,结构层次也更加清晰,应该会摆脱一些边缘场景的问题。 改造之后的使用方式同之前一致,用户并不会感知到。 只是为了说明下,我们对底层代码是有追求的,并会为了追去极致的代码优雅而去不停努力。 希望你们去使用LiteFlow,因为LF正在变得更强大。 解决了并行线程池的性能问题 源于社区的小伙伴在落地LF时发现,第一次请求会比后面的请求慢上一些。社区小伙伴也进行排查,发现LF是第一次请求...
- 下一篇
Netty/Incubator/Codec/OHTTP 0.0.4.Final 发布
netty-incubator-codec-ohttp 0.0.4.Final 正式版发布。与之前的版本相比,该版本包含各种错误修复和性能改进。此外,它还包含一个使用 BoringSSL 的 HPKE 本地实现。 该版本还包含为实现各种改进而必须进行的各种破坏性变更。 一些重点更新内容如下: 将枚举移出 OHttpCryptoProvider (#27) 将 OHttpCryptoProvider.supported* 方法替换为 isSupported(...) (#29) 抛出 OHttpCryptoReceiver.Builder.build() 时关闭 HPKERecipientContext(#34) 将 OHttpCryptoReceiver.Builder.setServerKeys(...) 替换为 OHttpCryptoReceiver.Builder.setSenderPrivateKey(...) (#35) 从 OHttpCiphersuite 中删除 bouncycastle 的导入(#37) 添加 OHttpCryptoProvider.newRandomP...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- CentOS8安装Docker,最新的服务器搭配容器使用
- Linux系统CentOS6、CentOS7手动修改IP地址
- 2048小游戏-低调大师作品
- Springboot2将连接池hikari替换为druid,体验最强大的数据库连接池
- CentOS8安装MyCat,轻松搞定数据库的读写分离、垂直分库、水平分库
- CentOS8编译安装MySQL8.0.19
- CentOS6,CentOS7官方镜像安装Oracle11G
- CentOS7,8上快速安装Gitea,搭建Git服务器
- SpringBoot2整合Thymeleaf,官方推荐html解决方案
- MySQL8.0.19开启GTID主从同步CentOS8