Bug in increment? #290

Closed
simo2409 opened this Issue Nov 19, 2012 · 3 comments

Comments

Projects
None yet
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

This comment has been minimized.

Show comment Hide comment
@lookatpete

lookatpete Nov 30, 2012

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

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

@simo2409

This comment has been minimized.

Show comment Hide comment
@simo2409

simo2409 Dec 28, 2012

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)

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

This comment has been minimized.

Show comment Hide comment
@mperham

mperham May 27, 2013

Collaborator

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.

Collaborator

mperham commented May 27, 2013

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 May 27, 2013

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