If you care about, as you say, "certain minute" you can use Ulf's gproc. If you want "last minute" then the ETS solution below will work well, with the modification on the Counter to use a ms/us timer like erlang:now().<div>
<div><br></div><div>-mox<br><br><div class="gmail_quote">On Fri, Aug 24, 2012 at 8:14 AM, Anders Nygren <span dir="ltr"><<a href="mailto:anders.nygren@gmail.com" target="_blank">anders.nygren@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Use an ETS table with {Counter,{YYYY,MM,DD,HH,MM}} as key, and<br>
ets:update_counter/2,3.<br>
update_counter returns the new counter value, so if it is 1, (or the<br>
increment used) You know that a new minute has been entered so You can<br>
delete the oldest.<br>
<br>
/Anders<br>
<div><div class="h5"><br>
On Fri, Aug 24, 2012 at 9:16 AM, Max Bourinov <<a href="mailto:bourinov@gmail.com">bourinov@gmail.com</a>> wrote:<br>
> Dear Erlangers,<br>
><br>
> Does anybody know best memory efficient way to count events within last XX<br>
> minutes?<br>
><br>
> So far I have the following idea: For each counter I have a process. The<br>
> counter process has a list of XX items. Each item represents a certain<br>
> minute, so I always know where is my current counter. There is also must be<br>
> a mechanism to remove last item from the list and add a new one. Summing<br>
> values from all items is a number of events within last XX minutes. This is<br>
> it.<br>
><br>
> Maybe there is a ready lib that does the same in a better way?<br>
><br>
> Any suggestions are welcome!<br>
><br>
> Best regards,<br>
> Max<br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div></div>