Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bug in increment? #290

Closed
simo2409 opened this Issue · 3 comments

3 participants

@simo2409

Hello,
I have troubles using increment, it returns nil and it doesn't update value in memcached, I can't understand if I'm wronging something or if there is a bug.

1.9.3p194 :001 > Rails.cache.read('foo')
=> nil
1.9.3p194 :002 > Rails.cache.write('foo', 1)
=> true
1.9.3p194 :003 > Rails.cache.read('foo')
=> 1
1.9.3p194 :004 > Rails.cache.increment('foo', 1)
=> nil
1.9.3p194 :005 > Rails.cache.read('foo')
=> 1

I would expect after .increment to have 'foo' = 2

Thank you

@lookatpete

I copied your commands and got the expected result. Are you still having this problem?

@simo2409

yes the problem is still there (I also updated to Dalli 2.5.0 but nothing changed)

I'm doing this inside rails console using rails 3.2.9 running on ruby 1.9.3p327 (if it can be useful to understand where the problem is)

@mperham
Owner

You do not read or write incremented values, this is not legal in memcached. You use increment(value, 1) to increment the counter and use increment(value, 0) to read the current value.

@mperham mperham closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.