简体   繁体   English

php进度条通过数据库

[英]php progress bar through database

I need to run long (mintues to hours) matlab code on server side and send the user its progress status (0-100%). 我需要在服务器端运行长时间(数分钟至数小时)的matlab代码,并将其进度状态(0-100%)发送给用户。 I can't send the data directly to client-side because the client may disconnect and check the status hours later. 我无法将数据直接发送到客户端,因为客户端可能会断开连接并在数小时后检查状态。

Should I do it through the database? 我应该通过数据库吗? Thought about updating the database through matlab/php while the client side (php via javascript/ajax) can query the database every few seconds but I am afraid its very "expensive" (many read & write operations for only one user). 考虑过通过matlab / php更新数据库,而客户端(通过javascript / ajax通过php)可以每隔几秒钟查询一次数据库,但恐怕它非常“昂贵”(许多读和写操作仅针对一个用户)。

What should I do? 我该怎么办? by the way, its an internal network, dozenes of users, no more. 顺便说一下,它的内部网络只有数十个用户。

You did not mention the kind of database you are using. 您没有提及正在使用的数据库类型。 If it is mysql and since you are only in an internal network with some dozens users: yes you can use the database. 如果是mysql,并且由于您仅处于具有数十个用户的内部网络中,则可以使用数据库。 If you want to keep read/write-operations low, you can use the MEMORY-Database-Engine for that purpose. 如果您想保持较低的读/写操作,则可以为此目的使用MEMORY-Database-Engine。

Also, you can use Memcache for interprocess-communication. 另外,您可以使用Memcache进行进程间通信。 One process writes into memcache, and another process reads the value out. 一个进程写入内存缓存,另一个进程读取该值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM