expires_in issue at Rails.cache.increment #346

maxguzenski opened this Issue Mar 26, 2013 · 1 comment

2 participants


I've a strange issue, sometime it works, sometimes not, example:

    time_to_expire = (Time.now.end_of_day - Time.now).floor.seconds
    limit                = 50

    if Rails.cache.increment(:"user:#{current_user.id}:messages:count", 1, {:expires_in => time_to_expire}) > limit
      raise CanCan::AccessDenied.new("Without limit!", :limit_to, type)

I have some users with 3 days cache without reset its increment key...


@maxguzenski If I'm understanding the issue correctly, your TTL doesn't appear to be behaving as expected - you're setting a TTL of less than a day and you see long lived entries.

There is a bug in this code which may be causing the issue - in some cases the time_to_expire value can be 0, which is a 'never expire' entry. Depending on how frequently the messages count is getting hit, this may be the source of the observed problem.

As this is an old issue that never got any follow up, I'm going to close. Please reopen if you're still seeing the same problem on a recent version of Dalli.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment