c - G-WAN 在使用 mongoDB 时表现异常

标签 c mongodb g-wan

我正在使用 G-WAN 和 mongoDB,我有一个奇怪的行为。当我显示我的页面时,它看起来不错。如果我刷新它,它将在 5 或 6 次刷新后停止工作。

这里是代码

// ============================================================================
// C servlet sample for the G-WAN Web Application Server (http://trustleap.ch/)
// ----------------------------------------------------------------------------
// mongodb.c: querying mongoDB from G-WAM
// ============================================================================

#pragma link "mongoc"
#pragma link "bson"

#include <mongo.h>
#include <bson.h>
#include "gwan.h" // G-WAN exported functions

int main(int argc, char *argv[])
{
  u64 start = getus();
  xbuf_t *reply = get_reply(argv);
  mongo conn[1];
  int status = mongo_client( conn, "localhost", 27017 );

  if( status != MONGO_OK ) {
    xbuf_xcat(reply, "ERROR MONGO %d", status);

  }

  int i = 0;
  for(i=0; i<2;i++) {
    bson b[1];
    bson_init( b );
    bson_append_new_oid( b, "_id" );
    bson_append_string( b, "name", "Joe" );
    bson_append_int( b, "age", 33 );
    bson_finish( b );
    mongo_insert( conn, "tutorial.people", b, NULL );
    bson_destroy( b );
  }

  xbuf_xcat(reply, "Hello Mongo !! %llU %d %d %llU micro seconds", getus(), status, i, (getus() - start));

  mongo_destroy(conn);
  return 200;
}
// ============================================================================
// End of Source Code
// ============================================================================

日志中没有什么特别的……

[Fri Apr 26 06:36:57 2013 GMT] 127.0.0.1 "GET /?forum.c" 200 60 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0"

浏览器看起来卡住了,并且 getus() 值没有刷新...就像显示 g-wan 缓存版本一样...

[更新] 我认为这是一个 G-WAN 内部缓存问题...更改我的 url 并向其添加一些参数刷新页面...

感谢您的帮助。

最佳答案

此版本中的微缓存生命周期显然过长,但如何绕过它是well-documented .

关于c - G-WAN 在使用 mongoDB 时表现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16230262/

相关文章:

java - 是否有可能(以及如何)改变 G-WAN 处理请求的方式?

c++ - 有没有可以用来代替脚本的低级语言?

c - 归并排序程序出错

python - 使用 Python 结构模块解压 C 结构

c++ - 在不需要的宏使用上强制出现 C++ 错误

javascript - Javascript 循环对象时未定义

创建 C 子字符串 : looping with assignment operator VS strncopy, 哪个更好?

javascript - 有没有什么方法可以在不迭代的情况下从对象数组中创建属性数组?

mongodb - MongoDB 3.0.2 中不存在 `cleanupOrphaned`?

c - gwan是如何实现异步 Action 的?