This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Passing a proc as period value results in count being reset #464
Labels
You can continue the conversation there. Go to discussion →
I'm experiencing some odd behavior while attempting to pass a proc as an argument to a throttle
period
.I tried following the suggestion to use a proc by @ktheory in #81 (comment), as my use case is very similar.
The following code appears to work fine for me:
However, when I changed the
period_proc
above to use#end_of_day
instead, the value is calculated properly, but each request seems to result in a new throttle being created, and thecount
value never surpasses 1:My understanding is that the ID showing up in the logs corresponds to a current throttle period, and a new one is created after a current throttle period expires. This ID was being incremented on each new request, even though the period had not ended
The ID using the
#end_of_month
code remained consistent, as far as I saw.Out of curiosity, I tried using
#end_of_week
, and the count would reset seemingly sporadically, creating showing an incremented ID when the count went back to 1 (without hitting the limit).It seems that the problem is actually occurring in each scenario, but when the proc yields lower values, it happens more reliably. My guess is that something is busting the cache, but I'm not sure why, or how to explain the discrepancy in behavior.
I'm using v5.4.2 of the gem on Ruby 2.2 with
ActiveSupport::Cache::DalliStore
.Any guidance is very much appreciated!
The text was updated successfully, but these errors were encountered: