English 中文(简体)
时间窗口圆桌会议
原标题:RoundRobin by Time Window

I m 寻找一个储存的现成价值的系统,并自动消除的现时值

Something like a RoundRobin system but, as long I understand, RoundRobin is based in an specific amount of records and removing as much old ones as much new ones are coming.

在这一制度中,可是任何数额记录,而只是删除那些高于特定时间滞后的记录。

一种近似可是一种系统,每个记录都有预留时间:

console.append "key", { :value => "value1", :timeout => 10.minutes_in_the_future }
console.append "key", { :value => "value2", :timeout => 10.minutes_in_the_future }
console.append "key", { :value => "value3", :timeout => 10.minutes_in_the_future }

And somehow the system is in charge to remove any expired record.

该系统可以建立在任何高性能储存系统(Redis, Memcache, ......)之上。

我不想仅仅想详细解释如何实施某种启发或任何相关的条款或现有制度,这样我就不希望发明轮.。

问题回答

Memcache aprox

在办公室里,我们正在研究这一规定:

Preconditions

  • The time window is 10 minutes.
  • We only need to know the amount of records and not the values.
  • We can live with not very accurate solution.

Implementation

  1. Create a new key every minute like: mykey_<Time.now.strftime("%Y%m%d%H%M")>.
  2. Give them a expire time of 10 minutes.
  3. Every time we want to add a record we incr the key for our actual minute.
  4. To calculate the time window value we get the values of the 10 keys for the last 10 minutes and sum them.

Cons

  • We can not store real values but only one accumulate.
  • When every 1 minute key is expired the total value fluctuates suddenly.




相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签