Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expires_in issue at Rails.cache.increment #346

Closed
maxguzenski opened this issue Mar 26, 2013 · 1 comment
Closed

expires_in issue at Rails.cache.increment #346

maxguzenski opened this issue Mar 26, 2013 · 1 comment

Comments

@maxguzenski
Copy link

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)
    end

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

@petergoldstein
Copy link
Owner

@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.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants