totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 450 forks source link

Database counter seems not working #715

Closed aalfiann closed 5 years ago

aalfiann commented 5 years ago

Hello,

I have database like this users.nosql

{"id":"19070212570001dnd1","name":"Aziz","datecreated":"2019-07-02T05:57:58.476Z"}
{"id":"19070212570002dnd0","name":"Tika","datecreated":"2019-07-02T05:57:58.476Z"}

Here is my test:

  var users = NOSQL('users');
  for(var i=0;i<10;i++){
    // add count
    users.counter.hit('19070212570002dnd0',1);
  }
  users.counter.count(function(err,response){
      console.log(response);
  });

The output is always 0.

But after a minutes later, the output is 10. I've seen that there is new file users.nosql-counter2 created.

My question is how this is work? is this using built-in cache? how long this will refreshed? Is stats_sum will working since there is no any date in users.nosql-counter2 file?

Also I didn't found any example in totaljs github about using database counter in detail.

So please help me to understand this great framework.

Thank you

aalfiann commented 5 years ago

I close this issue because the counter is working. I hope there is an example to use database container with detail explanation. Thank you.

petersirka commented 5 years ago

Hi @aalfiann. the counter doesn't count current cached stats. The reason (maybe) is that it's complicated count cache when stats are counted. I want to improve mechanism and storing data in future version.

Currently there is 30 seconds delay for flushing of cache. Just let me know if you have any questions or we can discuss about it on Total.js messenger.