小编Der*_*rek的帖子

AJAX轮询频率 - 长期民意调查还是不长期民意调查?

我正在构建一个需要相对不变的数据库轮询的网页组件.我可以看到两种不同的方法,我想知道其中一种是否比其他方法更好,或者我是否缺少第三种选择.

1)每隔1或2秒发送一次AJAX请求以检查更新.无论是否有新数据,每个请求都会立即返回.
2)触发单个AJAX请求,该请求在收到数据或发生超时之前不会返回.在其中任何一个发生时,它会触发下一个请求.(我认为这叫做长轮询?)

数据库查询的数量与之相同,但使用#2,从浏览器发出的请求将减少,这可以节省带宽和客户端资源.对于服务器,最好让一个PHP请求保持活动状态并在查询之间休眠,或者每隔几秒触发一次,轮询数据库,然后关闭?或者没有区别,我对此太过强调了?

编辑:我想我还应该声明这是一个更大的网络应用程序的聊天小部件.通信的轻微延迟不会杀死用户,因为聊天是次要功能.

php ajax performance comet long-polling

14
推荐指数
1
解决办法
4621
查看次数

MySQL查询每60秒重启一次?

我有一个奇怪的问题.我正在对PHP中的一个非常大的表运行MySQL查询.查询时间超过一分钟,但这不是我的问题.看起来PHP每66秒重新发送一次查询.

show processlist;
+--------+---------+-------------------+----------+---------+------+---------------+--------------------------------------------------------
| Id     | User    | Host              | db       | Command | Time | State         | Info                                                   
+--------+---------+-------------------+----------+---------+------+---------------+--------------------------------------------------------
| 150018 | root    | localhost         | amrs     | Query   |   32 | Sending data  | /*DEREK*/select ctlno, count(*) AS count from (omitted)
Run Code Online (Sandbox Code Playgroud)

几分钟后,我再次检查:

+--------+---------+-------------------+----------+---------+------+---------------+--------------------------------------------------------
| Id     | User    | Host              | db       | Command | Time | State         | Info                                                   
+--------+---------+-------------------+----------+---------+------+---------------+--------------------------------------------------------
| 150018 | root    | localhost         | amrs     | Query   |  188 | Sending data  | /*DEREK*/select …
Run Code Online (Sandbox Code Playgroud)

php mysql

8
推荐指数
1
解决办法
686
查看次数

突出显示Vim中的搜索但不是替换?

我知道可以阻止Vim突出显示任何搜索,但有没有办法让它在常规搜索中突出显示,但不是,例如,替换?

我经常会突出显示一段文字然后执行以下操作:

:s/^/#/
Run Code Online (Sandbox Code Playgroud)

评论整个街区.但后来我的屏幕左侧有一个丑陋的黄色条,我:noh每次都要清除它.

我希望突出显示继续定期/搜索.这可能吗?

vim

7
推荐指数
1
解决办法
617
查看次数

XmlNode InnerXml与OuterXml

我遇到了一个奇怪的情况,希望有一个比我了解得更多的人可以帮助我解决这个问题。

我正在将图像插入Xml文档中,以便可以使用Microsoft Word打开它。作为其中的一部分,我需要添加一个映射到包含图像的元素的Xml'Relationship'。直截了当。

我添加的节点应如下所示:

<Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image1.png"  />
Run Code Online (Sandbox Code Playgroud)

但是,在最终的.doc文件中,该行显示如下:

<Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image1.png" xmlns="" />
Run Code Online (Sandbox Code Playgroud)

即它现在具有一个空的xmlns =“”属性。

这足以让Word相信文档已损坏并拒绝打开。如果我手动打开文件并删除该属性,则会打开文件。

显然,我想以编程方式删除它:-)所以我找到了父节点。这是我的理解有些模糊的地方。我相信OuterXml元素包含节点及其所有子元素的内容,而InnerXml仅包含子元素。

这就是我所看到的(请注意,转义字符是因为我是从Visual Studio的文本查看器中剪切下来的)。

外层Xml:

"<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">
<Relationship Id=\"rId3\"     Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings\" Target=\"webSettings.xml\" />
 <Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\" Target=\"settings.xml\" />
<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\" />
<Relationship Id=\"rId5\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\" Target=\"theme/theme1.xml\" />
<Relationship Id=\"rId4\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\" Target=\"fontTable.xml\" />
<Relationship Id=\"rId6\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\" Target=\"media/image1.png\" xmlns=\"\" />

</Relationships>"
Run Code Online (Sandbox Code Playgroud)

InnerXml:

"<Relationship Id=\"rId3\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings\" Target=\"webSettings.xml\" xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\" />
<Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\" Target=\"settings.xml\" xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\" />
<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\" xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\" />
<Relationship Id=\"rId5\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\" Target=\"theme/theme1.xml\" …
Run Code Online (Sandbox Code Playgroud)

xml innerxml xmlnode outerxml

6
推荐指数
1
解决办法
4107
查看次数

通过 Spring Boot application.yml 配置 Hazelcast

我能够使用 hazelcast.xml 文件在我的 Spring Boot 应用程序中使用 Hazelcast 缓存。但是,该应用程序有多个配置文件,我试图避免管理多个 hazelcast.xml 文件。我想配置 application.yml 中的所有选项。如果我正确理解文档,我应该能够在 application.yml 中执行以下操作,对吗?

hazelcast:
  client:
    config:
      network:
        join:
          tcp-ip:
            member:
              - 1.2.3.4
              - 9.8.7.6
      map:
        name: user-details
        max-size: 1000
        eviction-policy: LRU
        eviction-percentage: 10
        time-to-live-seconds: 900
Run Code Online (Sandbox Code Playgroud)

除非它不起作用。我尝试查找通过 application.yml 配置 Hazelcast 的其他参考,但没有找到。我想做的事情是不可能的吗?

java spring hazelcast spring-boot

4
推荐指数
2
解决办法
1万
查看次数

Div不以IE为中心

我相信你之前已经听过了......虽然它在Chrome和Firefox中完美运行,但div并没有正确地在IE中居中.我已经研究过并尝试过使用text-align和auto margin的东西但是空洞了.我也尝试用另一个div或其他东西替换标签,但没有任何积极的结果.任何人都可以提供任何见解将不胜感激.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.thumbnails {
    background-color:white;
    border: solid 1px #000099;
    height:120px;
    width: 640px;
    overflow-y:scroll;
    margin-bottom:20px;
    position:relative;
    padding-top: 10px;
}

#hugeimage {
    background-color:white;
    border-top: solid 1px #000099;  
    border-left: solid 1px #000099;
    border-right: solid 1px #000099;
    height:550px;
    width: 640px;
    display:table-cell; 
    vertical-align:middle;
}

#hugeimage a,
#hugeimage img {
    margin: 0px;
    padding: 0px;
    border: 0px;
}

#imageinfo {
    background-color:white;
    border-left: solid 1px #000099;
    border-right: solid 1px #000099;
    width: …
Run Code Online (Sandbox Code Playgroud)

html css internet-explorer

2
推荐指数
1
解决办法
5994
查看次数