我的应用程序需要轮询MySQL数据库以获取新行.每次添加新行时,都应检索它们.我正在考虑创建一个触发器,以在单独的表上放置对新行的引用.原始表有超过300,000行.
该应用程序是用PHP构建的.
一些好的答案,我认为这个问题值得赏心悦目.
我通过迭代ping在网络中调查了很多设备(超过300个).
程序按顺序轮询设备,因此速度很慢.我想提高民意调查的速度.
在Delphi 7中有一些方法可以做到这一点:
什么是更快,更容易?请举例说明一些示例或链接.
我试图在内核驱动程序和用户空间程序之间异步通信(我知道这里有很多问题需要类似的信息,但我找不到任何处理sysfs_notify的问题).
我将离开Vilhelm的编辑,但是将源添加到使用sysfs的简单驱动程序和用户空间程序进行轮询.驱动程序工作正常(我从网上得到了大部分;它缺少了学分,但是当我回去添加它们时我找不到它们).不幸的是,投票计划不起作用.它总是立即返回成功.有趣的是,如果我在轮询之前不执行两次读取,则revents成员将设置为POLLERR | 如程序输出中所见,POLLIN而不仅仅是POLLIN.
节目输出:
root @ ubuntu:/ home/wmulcahy/demo#./ readhello
triggered
属性文件值:74(t)[0]
revents [0]:00000001
revents [1]:00000001
这是驱动程序:hello.c(你可以看到我开始的地方......)
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/slab.h>
struct my_attr {
struct attribute attr;
int value;
};
static struct my_attr notify = {
.attr.name="notify",
.attr.mode = 0644,
.value = 0,
};
static struct my_attr trigger = {
.attr.name="trigger",
.attr.mode = 0644,
.value = 0,
};
static struct attribute * myattr[] = {
¬ify.attr,
&trigger.attr,
NULL
};
static ssize_t show(struct kobject *kobj, …Run Code Online (Sandbox Code Playgroud) 我正在使用PrimeFaces民意调查组件刷新一些内容.
<h:form id="formBsvtt">
<p:messages autoUpdate="true" showDetail="false" />
<p:outputPanel id="panelOut" layout="block">
...
... content to refresh
...
</p:outputPanel>
<p:panelGrid id="panelIn" layout="block">
...
... various input components with validation
...
</p:panelGrid>
<p:poll widgetVar="poll1" autoStart="true" global="false" interval="15"
partialSubmit="true" process="@this" update="panelOut"
listener="#{myBean.myListener}">
</p:poll>
</h:form>
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我正在使用autoUpdate = true的消息.我的问题是:如果出现验证错误,将显示FacesMessages,但不会迟于15秒消失.
是否可以在不设置消息autoUpdate = false的情况下阻止轮询清除FacesMessages?
我的Web应用程序比上面指定的代码片段大得多,我的意图是不在每种可能的情况下手动更新消息!
我正在尝试在Laravel中编写长轮询功能,但是当我使用sleep()函数时,整个应用程序会冻结/阻塞,直到sleep()函数完成.有谁知道如何解决这个问题?
我的javascript看起来像这样:
function startRefresh() {
longpending = $.ajax({
type: 'POST',
url: '/getNewWords',
data: { wordid: ""+$('.lastWordId').attr('class').split(' ')[1]+"" },
async: true,
cache: false
}).done(function(data) {
$("#words").prepend(data);
startRefresh();
});
}
Run Code Online (Sandbox Code Playgroud)
和PHP:
public function longPolling()
{
$time = time();
$wordid = Input::get('wordid');
session_write_close();
//set_time_limit(0);
while((time() - $time) < 15) {
$words = Word::take(100)->where('id', '>', $wordid)
->orderBy('created_at', 'desc')->get();
if (!$words->isEmpty()) {
$theView = View::make('words.index', ['words' => $words])->render();
if (is_object($words[0])) {
$theView .= '<script>
$(".lastWordId").removeClass($(".lastWordId").attr("class")
.split(" ")[1]).addClass("'.$words[0]->id.'");
</script>';
}
return $theView;
} else {
sleep(2); …Run Code Online (Sandbox Code Playgroud) 我正在使用AngularJS和ASP.Net WebAPI开发客户端单页面应用程序(SPA).
SPA的一个功能包括上载大型CSV文件,在服务器上处理它,以及将输出返回给用户.
显然,这种计算不能在线完成,因此我实现了一个负责接收文件的UploadController,以及一个负责在计算完成时通知用户的PollingController.
客户端应用程序每隔几秒钟监视一次PollingController.
我没有消息队列的经验,但我的直觉告诉我他们在这种情况下是必需的.
您如何建议以非阻塞,高效的方式实现此功能?

举例将受到高度赞赏
我想在PHP中创建类似于加载器的东西,所以我使用了这段代码:
<?php
$x=1;
while($x<=100) {
echo "Loading: $x %<br>";
$x++;
}
?>
Run Code Online (Sandbox Code Playgroud)
这样它将显示从"加载1%"到"加载100%".但是,这将导致所有出现的一个在新线出现后不会消失.因此,我想知道如何使新行显示并且旧的消失,并且这在页面加载后开始,因此用户将能够观看实际加载的加载器从1%到100%.
更新:我知道我应该使用JS和/或Ajax来实现它,我只是想知道是否有办法在PHP中也这样做:)
我有一个Web应用程序,它使用与其他Web应用程序共享的SQL Server数据库(我无法控制).我必须知道任何Web应用程序何时对数据库中的某些表进行更改.
我的第一个想法是使用SqlDependency(具体来说SqlTableDependency,因为我需要知道更改的数据),但我担心性能问题.
我想知道是否有任何性能比较SqlDependency(非SqlTableDependency),触发器(触发WS,exe等)和轮询.
我发现了一些问题和文章,但对我来说还不够清楚
其他信息:
谢谢!
问题是如何设计执行耗时作业(几秒和几分钟的数量级)的 REST Web 服务。
最快的解决方案是按如下方式进行:
GET /job/:id/status);GET /job/:id/result)。我不喜欢的是步骤 2,因为许多作业正在进行中,服务器不必要地超载。为了避免这种情况,我想到了另外两种解决方案:
所有三个解决方案都有我不喜欢的方面:
还有其他解决方案吗?如果不是,您认为这三个中哪一个更可靠?
我有这个工作但我正在采用更"最佳实践方式".
它使用https:// icanhazdadjoke api来显示每x秒更新一次的随机笑话.有更好的方法吗?
最终我想添加停止,启动,重置功能,并觉得这种方式可能不是最好的.
我可以用的任何中间件?
Redux动作
// action types
import axios from 'axios';
export const FETCH_JOKE = 'FETCH_JOKE';
export const FETCH_JOKE_SUCCESS = 'FETCH_JOKE_SUCCESS';
export const FETCH_JOKE_FAILURE = 'FETCH_JOKE_FAILURE';
function fetchJoke() {
return {
type: FETCH_JOKE
};
}
function fetchJokeSuccess(data) {
return {
type: FETCH_JOKE_SUCCESS,
data
};
}
function fetchJokeFail(error) {
return {
type: FETCH_JOKE_FAILURE,
error
};
}
export function fetchJokeCall(){
return function(dispatch){
dispatch(fetchJoke());
return axios.get('https://icanhazdadjoke.com', { headers: { 'Accept': 'application/json' }})
.then(function(result){
dispatch(fetchJokeSuccess(result.data))
})
.catch(error => dispatch(fetchJokeFail(error)));
} …Run Code Online (Sandbox Code Playgroud) polling ×10
php ×3
triggers ×2
ajax ×1
apache ×1
asp.net-mvc ×1
asynchronous ×1
delphi ×1
iocp ×1
javascript ×1
jsf ×1
kernel ×1
laravel ×1
linux ×1
linux-kernel ×1
loading ×1
long-integer ×1
loops ×1
msmq ×1
mysql ×1
ping ×1
primefaces ×1
reactjs ×1
redux ×1
rest ×1
sql-server ×1
sysfs ×1