-1

This is the output of my rails console after I include rubygems and redis.

2.0.0-p353 :024 > r = Redis.new
=> #<Redis client v3.0.7 for redis://127.0.0.1:6379/0> 
2.0.0-p353 :025 > r.set('foo','bar')
=> "OK" 
2.0.0-p353 :026 > r.get('foo')
=> "bar"
2.0.0-p353 :033 > r.lpush('foo','bar')
Redis::CommandError: ERR Operation against a key holding the wrong kind of value
from /home/poorva/.rvm/gems/ruby-2.0.0-p353/gems/redis-3.0.7/lib/redis/client.rb:97:in `call'
from /home/poorva/.rvm/gems/ruby-2.0.0-p353/gems/redis-3.0.7/lib/redis.rb:949:in `block in lpush'
from /home/poorva/.rvm/gems/ruby-2.0.0-p353/gems/redis-3.0.7/lib/redis.rb:37:in `block in synchronize'
from /home/poorva/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
from /home/poorva/.rvm/gems/ruby-2.0.0-p353/gems/redis-3.0.7/lib/redis.rb:37:in `synchronize'
from /home/poorva/.rvm/gems/ruby-2.0.0-p353/gems/redis-3.0.7/lib/redis.rb:948:in `lpush'
from (irb):33
from /home/poorva/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /home/poorva/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /home/poorva/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
2.0.0-p353 :034 > r.lpush(foo,'bar')
NameError: undefined local variable or method `foo' for main:Object
from (irb):34
from /home/poorva/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /home/poorva/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /home/poorva/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
poorva
  • 1,726
  • 1
  • 17
  • 15

1 Answers1

-1

Update: the first argument has to the first argument of the lpush command, that is to say the key of the list. and the second, the value to be pushed.


initial message (before the question was modified)

The message is explicit ArgumentError: wrong number of arguments (0 for 2). Just give LPUSH the expected arguments as described in Redis documentation : the key and the value to be pushed.

lpush('mylist', 'bar')
Pascal Le Merrer
  • 5,883
  • 20
  • 35
  • i had just printed the output r.lpush to show that method lpush exists. I knew it needs 2 arguments.Please read the logs carefully. – poorva Mar 24 '14 at 08:47
  • Update: the 'foo' and 'bar' value in my previous answer were just example, you should not have taken them literally :(. I updated my answer. – Pascal Le Merrer Mar 24 '14 at 12:12
  • r.lpush('boo','bar') gave me error was the problem. Later i checked in http://redis.io/topics/quickstart i had to install gem SystemTimer due to which i was getting an error - NameError: undefined local variable or method `boo' for main:Object – poorva Mar 24 '14 at 13:04